Update to release 1.0.0! Finished adding new compasses, textures, recipes, and working Netcode.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package net.yseven.findyourway.item;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -10,7 +11,9 @@ import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.yseven.findyourway.Client.ClientProxy;
|
||||
@@ -20,10 +23,10 @@ import net.yseven.findyourway.FindYourWay;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemCompassBase extends Item {
|
||||
private final String structureType;
|
||||
private String structureType;
|
||||
private BlockPos structurePos;
|
||||
private World structureWorld;
|
||||
public final String assetTag;
|
||||
private final int ItemCompassID;
|
||||
|
||||
public ItemCompassBase(String name, String structureName) {
|
||||
setUnlocalizedName(FindYourWay.modId + "." + name);
|
||||
@@ -31,30 +34,60 @@ public class ItemCompassBase extends Item {
|
||||
structureType = structureName;
|
||||
setCreativeTab(CreativeTabs.TOOLS);
|
||||
setMaxStackSize(1);
|
||||
assetTag = name + "_angle";
|
||||
CommonProxy.compassList.add(this);
|
||||
ItemCompassID = CommonProxy.compassList.indexOf(this);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
//getters
|
||||
|
||||
public String getStructureType() {
|
||||
return structureType;
|
||||
}
|
||||
|
||||
public void setStructurePos(BlockPos pos) {
|
||||
structurePos = pos;
|
||||
}
|
||||
|
||||
public BlockPos getStructurePos() {
|
||||
return structurePos;
|
||||
}
|
||||
public World getStructureWorld() {
|
||||
return structureWorld;
|
||||
}
|
||||
public int getCompassID() {
|
||||
return ItemCompassID;
|
||||
}
|
||||
|
||||
//setters
|
||||
|
||||
public void setStructureType(String type) {
|
||||
structureType= type;
|
||||
}
|
||||
public void setStructurePos(BlockPos pos) {
|
||||
structurePos = pos;
|
||||
}
|
||||
public void setStructureWorld(World world) {
|
||||
structureWorld = world;
|
||||
}
|
||||
|
||||
public World getStructureWorld() {
|
||||
return structureWorld;
|
||||
//netcode implementation
|
||||
|
||||
public void toBytes(ByteBuf buf) {
|
||||
if(CommonProxy.compassList.contains(this)) {
|
||||
buf.writeInt(ItemCompassID);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemCompassBase fromBytes(ByteBuf buf) {
|
||||
int ID = buf.readInt();
|
||||
for(int i = 0; i <= CommonProxy.compassList.size(); i++) {
|
||||
if(ID == CommonProxy.compassList.get(i).getCompassID()) return CommonProxy.compassList.get(i);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Client Code (mostly registration)
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void registerItemModel() {
|
||||
ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user