-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BlockLoom & Some skin check changes
- Loading branch information
Showing
9 changed files
with
152 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package cn.nukkit.block; | ||
|
||
import cn.nukkit.Player; | ||
import cn.nukkit.inventory.LoomInventory; | ||
import cn.nukkit.item.Item; | ||
import cn.nukkit.item.ItemBlock; | ||
import cn.nukkit.item.ItemTool; | ||
import cn.nukkit.math.BlockFace; | ||
import cn.nukkit.utils.BlockColor; | ||
|
||
public class BlockLoom extends BlockSolidMeta { | ||
|
||
private static final short[] FACES = {2, 3, 0, 1}; | ||
|
||
public BlockLoom() { | ||
this(0); | ||
} | ||
|
||
public BlockLoom(int meta) { | ||
super(meta); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "Loom"; | ||
} | ||
|
||
@Override | ||
public int getId() { | ||
return LOOM; | ||
} | ||
|
||
@Override | ||
public int getToolType() { | ||
return ItemTool.TYPE_AXE; | ||
} | ||
|
||
@Override | ||
public double getResistance() { | ||
return 12.5; | ||
} | ||
|
||
@Override | ||
public double getHardness() { | ||
return 2.5; | ||
} | ||
|
||
@Override | ||
public BlockColor getColor() { | ||
return BlockColor.WOOD_BLOCK_COLOR; | ||
} | ||
|
||
@Override | ||
public boolean canBeActivated() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onActivate(Item item, Player player) { | ||
if (player != null) { | ||
player.addWindow(new LoomInventory(player.getUIInventory(), this), Player.LOOM_WINDOW_ID); | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public Item toItem() { | ||
return new ItemBlock(Block.get(this.getId(), 0), 0); | ||
} | ||
|
||
@Override | ||
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { | ||
this.setDamage(FACES[player != null ? player.getDirection().getHorizontalIndex() : 0]); | ||
return this.getLevel().setBlock(this, this, true, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package cn.nukkit.inventory; | ||
|
||
import cn.nukkit.Player; | ||
import cn.nukkit.item.Item; | ||
import cn.nukkit.level.Position; | ||
|
||
public class LoomInventory extends FakeBlockUIComponent { | ||
|
||
public static final int OFFSET = 9; | ||
|
||
public LoomInventory(PlayerUIInventory playerUI, Position position) { | ||
super(playerUI, InventoryType.LOOM, OFFSET, position); | ||
} | ||
|
||
@Override | ||
public void onOpen(Player who) { | ||
super.onOpen(who); | ||
who.craftingType = Player.CRAFTING_LOOM; | ||
} | ||
|
||
public Item getFirstItem() { | ||
return getItem(0); | ||
} | ||
|
||
public Item getSecondItem() { | ||
return getItem(1); | ||
} | ||
|
||
public void setFirstItem(Item item) { | ||
this.setItem(0, item); | ||
} | ||
|
||
public void setSecondItem(Item item) { | ||
this.setItem(1, item); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters