mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Booklet Stand
This commit is contained in:
parent
e46c4f217a
commit
8a40cf9e15
12 changed files with 480 additions and 0 deletions
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* This file ("BlockBookletStand.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.ActuallyAdditions;
|
||||
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
||||
import ellpeck.actuallyadditions.items.InitItems;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityBookletStand;
|
||||
import ellpeck.actuallyadditions.util.AssetUtil;
|
||||
import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockBookletStand extends BlockContainerBase implements IActAddItemOrBlock{
|
||||
|
||||
public BlockBookletStand(){
|
||||
super(Material.rock);
|
||||
this.setHarvestLevel("pickaxe", 0);
|
||||
this.setHardness(1.5F);
|
||||
this.setResistance(10.0F);
|
||||
this.setStepSound(soundTypeStone);
|
||||
|
||||
float f = 1/16F;
|
||||
this.setBlockBounds(f, 0F, f, 1F-f, 1F-2*f, 1F-f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType(){
|
||||
return AssetUtil.bookletStandRenderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata){
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int f6, float f7, float f8, float f9){
|
||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.BOOK_STAND.ordinal(), world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
|
||||
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
|
||||
|
||||
if(rotation == 0){
|
||||
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||
}
|
||||
if(rotation == 1){
|
||||
world.setBlockMetadataWithNotify(x, y, z, 1, 2);
|
||||
}
|
||||
if(rotation == 2){
|
||||
world.setBlockMetadataWithNotify(x, y, z, 0, 2);
|
||||
}
|
||||
if(rotation == 3){
|
||||
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||
}
|
||||
|
||||
TileEntityBookletStand tile = (TileEntityBookletStand)world.getTileEntity(x, y, z);
|
||||
if(tile != null){
|
||||
//Assign a UUID
|
||||
if(tile.assignedPlayerUUID == null){
|
||||
tile.assignedPlayerUUID = player.getUniqueID();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconReg){
|
||||
this.blockIcon = InitItems.itemLexicon.getIcon(new ItemStack(InitItems.itemLexicon), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(){
|
||||
return "blockBookStand";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
return EnumRarity.rare;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int i){
|
||||
return new TileEntityBookletStand();
|
||||
}
|
||||
}
|
|
@ -104,9 +104,14 @@ public class InitBlocks{
|
|||
public static Block blockCrystal;
|
||||
public static Block blockAtomicReconstructor;
|
||||
|
||||
public static Block blockBookletStand;
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Blocks...");
|
||||
|
||||
blockBookletStand = new BlockBookletStand();
|
||||
BlockUtil.register(blockBookletStand);
|
||||
|
||||
blockAtomicReconstructor = new BlockAtomicReconstructor();
|
||||
BlockUtil.register(blockAtomicReconstructor);
|
||||
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* This file ("ModelBookletStand.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.blocks.render.model;
|
||||
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
public class ModelBookletStand extends ModelBaseAA{
|
||||
|
||||
ModelRenderer body1;
|
||||
ModelRenderer bottom1;
|
||||
ModelRenderer bottom2;
|
||||
ModelRenderer body2;
|
||||
ModelRenderer body3;
|
||||
ModelRenderer book1;
|
||||
ModelRenderer book2;
|
||||
ModelRenderer book3;
|
||||
ModelRenderer book4;
|
||||
|
||||
public ModelBookletStand(){
|
||||
textureWidth = 64;
|
||||
textureHeight = 64;
|
||||
|
||||
body1 = new ModelRenderer(this, 0, 0);
|
||||
body1.addBox(0F, 0F, 0F, 14, 8, 1);
|
||||
body1.setRotationPoint(-7F, 17F, 1F);
|
||||
body1.setTextureSize(64, 64);
|
||||
body1.mirror = true;
|
||||
setRotation(body1, -0.7853982F, 0F, 0F);
|
||||
bottom1 = new ModelRenderer(this, 25, 6);
|
||||
bottom1.addBox(0F, 0F, 0F, 1, 1, 8);
|
||||
bottom1.setRotationPoint(-5F, 23F, -5F);
|
||||
bottom1.setTextureSize(64, 64);
|
||||
bottom1.mirror = true;
|
||||
setRotation(bottom1, 0F, 0F, 0F);
|
||||
bottom2 = new ModelRenderer(this, 25, 6);
|
||||
bottom2.addBox(0F, 0F, 0F, 1, 1, 8);
|
||||
bottom2.setRotationPoint(4F, 23F, -5F);
|
||||
bottom2.setTextureSize(64, 64);
|
||||
bottom2.mirror = true;
|
||||
setRotation(bottom2, 0F, 0F, 0F);
|
||||
body2 = new ModelRenderer(this, 0, 10);
|
||||
body2.addBox(0F, 0F, 0F, 14, 1, 2);
|
||||
body2.setRotationPoint(-7F, 20.91F, -5F);
|
||||
body2.setTextureSize(64, 64);
|
||||
body2.mirror = true;
|
||||
setRotation(body2, -0.7853982F, 0F, 0F);
|
||||
body3 = new ModelRenderer(this, 0, 14);
|
||||
body3.addBox(0F, 0F, 0F, 10, 3, 1);
|
||||
body3.setRotationPoint(-5F, 20F, -1F);
|
||||
body3.setTextureSize(64, 64);
|
||||
body3.mirror = true;
|
||||
setRotation(body3, 0F, 0F, 0F);
|
||||
book1 = new ModelRenderer(this, 36, 0);
|
||||
book1.addBox(0F, 0F, 0F, 8, 10, 0);
|
||||
book1.setRotationPoint(0F, 15F, 3.1F);
|
||||
book1.setTextureSize(64, 64);
|
||||
book1.mirror = true;
|
||||
setRotation(book1, -0.837758F, 0.0872665F, 0F);
|
||||
book2 = new ModelRenderer(this, 36, 0);
|
||||
book2.addBox(0F, 0F, 0F, 8, 10, 0);
|
||||
book2.setRotationPoint(-8F, 15F, 3.1F);
|
||||
book2.setTextureSize(64, 64);
|
||||
book2.mirror = true;
|
||||
setRotation(book2, -0.837758F, 0F, 0F);
|
||||
book3 = new ModelRenderer(this, 0, 19);
|
||||
book3.addBox(0F, 0F, 0F, 7, 8, 1);
|
||||
book3.setRotationPoint(7F, 16F, 1.2F);
|
||||
book3.setTextureSize(64, 64);
|
||||
book3.mirror = true;
|
||||
setRotation(book3, 0.837758F, -3.054326F, 0F);
|
||||
book4 = new ModelRenderer(this, 0, 19);
|
||||
book4.addBox(0F, 0F, 0F, 7, 8, 1);
|
||||
book4.setRotationPoint(-7F, 15.3F, 1.2F);
|
||||
book4.setTextureSize(64, 64);
|
||||
book4.mirror = true;
|
||||
setRotation(book4, -0.837758F, 0F, 0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(float f){
|
||||
body1.render(f);
|
||||
bottom1.render(f);
|
||||
bottom2.render(f);
|
||||
body2.render(f);
|
||||
body3.render(f);
|
||||
book1.render(f);
|
||||
book2.render(f);
|
||||
book3.render(f);
|
||||
book4.render(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(){
|
||||
return "modelBookletStand";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesRotate(){
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z){
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* This file ("GuiBookStand.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.booklet;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.network.PacketBookletStandButton;
|
||||
import ellpeck.actuallyadditions.network.PacketHandler;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityBookletStand;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiBookletStand extends GuiBooklet{
|
||||
|
||||
private GuiButton buttonSetPage;
|
||||
|
||||
private TileEntityBookletStand theStand;
|
||||
|
||||
public GuiBookletStand(TileEntityBase theStand){
|
||||
super(null, false, false);
|
||||
this.theStand = (TileEntityBookletStand)theStand;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
|
||||
this.buttonSetPage = new GuiButton(-100, this.guiLeft+this.xSize+10, this.guiTop+10, 100, 20, "Set Page"){
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int x, int y){
|
||||
boolean unicodeBefore = mc.fontRenderer.getUnicodeFlag();
|
||||
mc.fontRenderer.setUnicodeFlag(false);
|
||||
super.drawButton(mc, x, y);
|
||||
mc.fontRenderer.setUnicodeFlag(unicodeBefore);
|
||||
}
|
||||
};
|
||||
this.buttonList.add(this.buttonSetPage);
|
||||
|
||||
this.buttonSetPage.visible = Minecraft.getMinecraft().thePlayer.getUniqueID().equals(this.theStand.assignedPlayerUUID);
|
||||
|
||||
//Open the pages the book was assigned
|
||||
BookletUtils.openIndexEntry(this, this.theStand.assignedEntry, this.theStand.assignedPageInIndex, true);
|
||||
BookletUtils.openChapter(this, this.theStand.assignedChapter, this.theStand.assignedPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(GuiButton button){
|
||||
if(button == this.buttonSetPage){
|
||||
PacketHandler.theNetwork.sendToServer(new PacketBookletStandButton(this.theStand.xCoord, this.theStand.yCoord, this.theStand.zCoord, this.theStand.getWorldObj(), Minecraft.getMinecraft().thePlayer, this.currentIndexEntry, this.currentChapter, this.currentPage, this.pageOpenInIndex));
|
||||
}
|
||||
super.actionPerformed(button);
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ import cpw.mods.fml.common.network.IGuiHandler;
|
|||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import ellpeck.actuallyadditions.ActuallyAdditions;
|
||||
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
||||
import ellpeck.actuallyadditions.booklet.GuiBookletStand;
|
||||
import ellpeck.actuallyadditions.inventory.gui.*;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
|
@ -144,6 +145,8 @@ public class GuiHandler implements IGuiHandler{
|
|||
return new GuiSmileyCloud(tile, x, y, z, world);
|
||||
case BOOK:
|
||||
return new GuiBooklet(null, true, true);
|
||||
case BOOK_STAND:
|
||||
return new GuiBookletStand(tile);
|
||||
case DIRECTIONAL_BREAKER:
|
||||
return new GuiDirectionalBreaker(entityPlayer.inventory, tile);
|
||||
case RANGED_COLLECTOR:
|
||||
|
@ -178,6 +181,7 @@ public class GuiHandler implements IGuiHandler{
|
|||
XP_SOLIDIFIER,
|
||||
CLOUD,
|
||||
BOOK(false),
|
||||
BOOK_STAND,
|
||||
DIRECTIONAL_BREAKER,
|
||||
RANGED_COLLECTOR;
|
||||
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* This file ("PacketBookletStand.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.network;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import ellpeck.actuallyadditions.booklet.InitBooklet;
|
||||
import ellpeck.actuallyadditions.booklet.chapter.BookletChapter;
|
||||
import ellpeck.actuallyadditions.booklet.entry.BookletEntry;
|
||||
import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityBookletStand;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
public class PacketBookletStandButton implements IMessage{
|
||||
|
||||
private int tileX;
|
||||
private int tileY;
|
||||
private int tileZ;
|
||||
private int worldID;
|
||||
private int playerID;
|
||||
|
||||
private int entryID;
|
||||
private int chapterID;
|
||||
private int pageID;
|
||||
private int pageInIndex;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public PacketBookletStandButton(){
|
||||
|
||||
}
|
||||
|
||||
public PacketBookletStandButton(int x, int y, int z, World world, EntityPlayer player, BookletEntry entry, BookletChapter chapter, BookletPage page, int pageInIndex){
|
||||
this.tileX = x;
|
||||
this.tileY = y;
|
||||
this.tileZ = z;
|
||||
this.worldID = world.provider.dimensionId;
|
||||
this.playerID = player.getEntityId();
|
||||
|
||||
this.entryID = entry == null ? -1 : InitBooklet.entries.indexOf(entry);
|
||||
this.chapterID = entry == null || chapter == null ? -1 : entry.chapters.indexOf(chapter);
|
||||
this.pageID = page == null ? -1 : page.getID();
|
||||
this.pageInIndex = pageInIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf){
|
||||
this.tileX = buf.readInt();
|
||||
this.tileY = buf.readInt();
|
||||
this.tileZ = buf.readInt();
|
||||
this.worldID = buf.readInt();
|
||||
this.playerID = buf.readInt();
|
||||
|
||||
this.chapterID = buf.readInt();
|
||||
this.pageID = buf.readInt();
|
||||
this.entryID = buf.readInt();
|
||||
this.pageInIndex = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf){
|
||||
buf.writeInt(this.tileX);
|
||||
buf.writeInt(this.tileY);
|
||||
buf.writeInt(this.tileZ);
|
||||
buf.writeInt(this.worldID);
|
||||
buf.writeInt(this.playerID);
|
||||
|
||||
buf.writeInt(this.chapterID);
|
||||
buf.writeInt(this.pageID);
|
||||
buf.writeInt(this.entryID);
|
||||
buf.writeInt(this.pageInIndex);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<PacketBookletStandButton, IMessage>{
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketBookletStandButton message, MessageContext ctx){
|
||||
World world = DimensionManager.getWorld(message.worldID);
|
||||
TileEntity tile = world.getTileEntity(message.tileX, message.tileY, message.tileZ);
|
||||
EntityPlayer player = (EntityPlayer)world.getEntityByID(message.playerID);
|
||||
|
||||
if(tile instanceof TileEntityBookletStand){
|
||||
if(player.getUniqueID().equals(((TileEntityBookletStand)tile).assignedPlayerUUID)){
|
||||
((TileEntityBookletStand)tile).setEntry(message.entryID, message.chapterID, message.pageID, message.pageInIndex);
|
||||
world.markBlockForUpdate(message.tileX, message.tileY, message.tileZ);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,5 +29,6 @@ public class PacketHandler{
|
|||
theNetwork.registerMessage(PacketGuiNumber.Handler.class, PacketGuiNumber.class, 1, Side.SERVER);
|
||||
theNetwork.registerMessage(PacketGuiString.Handler.class, PacketGuiString.class, 2, Side.SERVER);
|
||||
theNetwork.registerMessage(PacketAtomicReconstructor.Handler.class, PacketAtomicReconstructor.class, 3, Side.CLIENT);
|
||||
theNetwork.registerMessage(PacketBookletStandButton.Handler.class, PacketBookletStandButton.class, 4, Side.SERVER);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ public class ClientProxy implements IProxy{
|
|||
AssetUtil.phantomBoosterRenderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
AssetUtil.smileyCloudRenderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
AssetUtil.laserRelayRenderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
AssetUtil.bookletStandRenderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
registerRenderer(TileEntityCompost.class, new RenderTileEntity(new ModelCompost()), AssetUtil.compostRenderId);
|
||||
registerRenderer(TileEntityFishingNet.class, new RenderTileEntity(new ModelFishingNet()), AssetUtil.fishingNetRenderId);
|
||||
|
@ -82,6 +83,7 @@ public class ClientProxy implements IProxy{
|
|||
registerRenderer(TileEntityPhantomBooster.class, new RenderTileEntity(new ModelPhantomBooster()), AssetUtil.phantomBoosterRenderId);
|
||||
registerRenderer(TileEntitySmileyCloud.class, new RenderSmileyCloud(new ModelSmileyCloud()), AssetUtil.smileyCloudRenderId);
|
||||
registerRenderer(TileEntityLaserRelay.class, new RenderLaserRelay(new ModelLaserRelay()), AssetUtil.laserRelayRenderId);
|
||||
registerRenderer(TileEntityBookletStand.class, new RenderTileEntity(new ModelBookletStand()), AssetUtil.bookletStandRenderId);
|
||||
|
||||
VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/entity/villager/jamVillager.png"));
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ public abstract class TileEntityBase extends TileEntity{
|
|||
GameRegistry.registerTileEntity(TileEntityRangedCollector.class, ModUtil.MOD_ID_LOWER+":tileEntityRangedCollector");
|
||||
GameRegistry.registerTileEntity(TileEntityLaserRelay.class, ModUtil.MOD_ID_LOWER+":tileEntityLaserRelay");
|
||||
GameRegistry.registerTileEntity(TileEntityAtomicReconstructor.class, ModUtil.MOD_ID_LOWER+":tileEntityAtomicReconstructor");
|
||||
GameRegistry.registerTileEntity(TileEntityBookletStand.class, ModUtil.MOD_ID_LOWER+":tileEntityBookletStand");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* This file ("TileEntityBookletStand.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.tile;
|
||||
|
||||
import ellpeck.actuallyadditions.booklet.InitBooklet;
|
||||
import ellpeck.actuallyadditions.booklet.chapter.BookletChapter;
|
||||
import ellpeck.actuallyadditions.booklet.entry.BookletEntry;
|
||||
import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TileEntityBookletStand extends TileEntityBase{
|
||||
|
||||
public BookletChapter assignedChapter;
|
||||
public BookletPage assignedPage;
|
||||
public BookletEntry assignedEntry;
|
||||
public int assignedPageInIndex;
|
||||
|
||||
public UUID assignedPlayerUUID;
|
||||
|
||||
@Override
|
||||
public boolean canUpdate(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||
compound.setInteger("Entry", this.assignedEntry == null ? -1 : InitBooklet.entries.indexOf(this.assignedEntry));
|
||||
compound.setInteger("Chapter", this.assignedEntry == null || this.assignedChapter == null ? -1 : this.assignedEntry.chapters.indexOf(this.assignedChapter));
|
||||
compound.setInteger("Page", this.assignedPage == null ? -1 : this.assignedPage.getID());
|
||||
compound.setInteger("PageInIndex", this.assignedPageInIndex);
|
||||
|
||||
if(this.assignedPlayerUUID != null){
|
||||
compound.setLong("PlayerLeastSignificant", this.assignedPlayerUUID.getLeastSignificantBits());
|
||||
compound.setLong("PlayerMostSignificant", this.assignedPlayerUUID.getMostSignificantBits());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||
this.setEntry(compound.getInteger("Entry"), compound.getInteger("Chapter"), compound.getInteger("Page"), compound.getInteger("PageInIndex"));
|
||||
|
||||
long mostSigBits = compound.getLong("PlayerMostSignificant");
|
||||
if(mostSigBits > 0){
|
||||
this.assignedPlayerUUID = new UUID(mostSigBits, compound.getLong("PlayerLeastSignificant"));
|
||||
}
|
||||
}
|
||||
|
||||
public void setEntry(int entry, int chapter, int page, int pageInIndex){
|
||||
this.assignedEntry = entry == -1 ? null : InitBooklet.entries.get(entry);
|
||||
this.assignedChapter = chapter == -1 || entry == -1 || this.assignedEntry.chapters.size() <= chapter ? null : this.assignedEntry.chapters.get(chapter);
|
||||
this.assignedPage = chapter == -1 || this.assignedChapter == null || this.assignedChapter.pages.length <= page-1 ? null : this.assignedChapter.pages[page-1];
|
||||
this.assignedPageInIndex = pageInIndex;
|
||||
}
|
||||
}
|
|
@ -36,6 +36,7 @@ public class AssetUtil{
|
|||
public static int phantomBoosterRenderId;
|
||||
public static int smileyCloudRenderId;
|
||||
public static int laserRelayRenderId;
|
||||
public static int bookletStandRenderId;
|
||||
|
||||
/**
|
||||
* Thanks to xdjackiexd for this, as I couldn't be bothered
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 575 B |
Loading…
Reference in a new issue