Jump to content

MysteriousDevs

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by MysteriousDevs

  1. Yes but I don't want to use this gamerule
  2. Hello, I wanted to know, is it possible to add a condition at the level of the result anchor? Basically I would like to make sure that some craft is only accessible from a certain level of job(I already have the capa system). Or Use Advancement ystem (Basically if I have to use advancement I would like the recipe to be accessible only if and only if advancement is unlocked)
  3. Hello, I am confronted with a problem that is that the GUI of my custom chest appears peculiarlywhen I am in spectator mode, if someone has the solution I am taker. With that you will have the screen and the code. Thanks a lot Block : package mysteriousdevs.spellp.blocks; import fr.dofuscraft.dofuscraftcore.Dofuscraftcore; import mysteriousdevs.spellp.Main; import mysteriousdevs.spellp.handlers.GuiHandler; import mysteriousdevs.spellp.init.ModBlocks; import mysteriousdevs.spellp.init.ModItems; import mysteriousdevs.spellp.tileentity.TileEntityChestHouse; import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockFaceShape; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.tileentity.TileEntityEnderChestRenderer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.*; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockDCChestHouse extends BlockContainer { public static final PropertyDirection FACING = BlockHorizontal.FACING; protected static final AxisAlignedBB CHEST_AABB = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.875D, 0.9375D); public BlockDCChestHouse(String name) { super(Material.IRON); setUnlocalizedName(name); setRegistryName(name); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); setCreativeTab(Dofuscraftcore.blocks); ModBlocks.INSTANCE.getBlocks().add(this); } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return CHEST_AABB; } @Override public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { TileEntityChestHouse tileentity = (TileEntityChestHouse)worldIn.getTileEntity(pos); if(!worldIn.isRemote) { if(playerIn.isCreative()){ playerIn.openGui(Main.instance, GuiHandler.chestHouseGUI_ID, worldIn, pos.getX(), pos.getY(), pos.getZ()); } else if(tileentity.owner != null && tileentity.owner.equals(playerIn.getUniqueID().toString())){ playerIn.openGui(Main.instance, GuiHandler.chestHouseGUI_ID, worldIn, pos.getX(), pos.getY(), pos.getZ()); } else { playerIn.sendMessage(new TextComponentTranslation("msg.house_chest.noowner")); } } return true; } @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntityChestHouse tileentity = (TileEntityChestHouse)worldIn.getTileEntity(pos); InventoryHelper.dropInventoryItems(worldIn, pos, tileentity); super.breakBlock(worldIn, pos, state); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { if(stack.hasDisplayName()) { TileEntity tileentity = worldIn.getTileEntity(pos); if(tileentity instanceof TileEntityChestHouse) { ((TileEntityChestHouse)tileentity).setCustomName(stack.getDisplayName()); } } worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2); } @Override public IBlockState getStateFromMeta(int meta) { EnumFacing enumfacing = EnumFacing.getFront(meta); if (enumfacing.getAxis() == EnumFacing.Axis.Y) { enumfacing = EnumFacing.NORTH; } return this.getDefaultState().withProperty(FACING, enumfacing); } @Override public int getMetaFromState(IBlockState state) { return ((EnumFacing)state.getValue(FACING)).getIndex(); } @Override public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); } @Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {FACING}); } @Override public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { return BlockFaceShape.UNDEFINED; } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityChestHouse(); } @Override public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; } @Override public boolean isFullBlock(IBlockState state) { return false; } @Override public boolean isFullCube(IBlockState state) { return false; } @Override public boolean isOpaqueCube(IBlockState state) { return false; } } Container : package mysteriousdevs.spellp.container; import mysteriousdevs.spellp.tileentity.TileEntityChestHouse; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class ContainerChestHouse extends Container { private final int numRows; private final TileEntityChestHouse chestInventory; public ContainerChestHouse(InventoryPlayer playerInv, TileEntityChestHouse tileEntityCopperChest, EntityPlayer player) { this.chestInventory = tileEntityCopperChest; this.numRows = tileEntityCopperChest.getSizeInventory() / 9; tileEntityCopperChest.openInventory(player); for(int i = 0; i < this.numRows; ++i) { for(int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(tileEntityCopperChest, j + i*9, 8 + j*18, 18 + i*18)); } } for(int y = 0; y < 3; y++) { for(int x = 0; x < 9; x++) { this.addSlotToContainer(new Slot(playerInv, x + y*9 + 9, 8 + x*18, 175 + y*18)); } } for(int x = 0; x < 9; x++) { this.addSlotToContainer(new Slot(playerInv, x, 8 + x*18, 233)); } } @Override public boolean canInteractWith(EntityPlayer playerIn) { return this.chestInventory.isUsableByPlayer(playerIn); } @Override public void onContainerClosed(EntityPlayer playerIn) { super.onContainerClosed(playerIn); chestInventory.closeInventory(playerIn); } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (index < this.numRows * 9) { if (!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false)) { return ItemStack.EMPTY; } if (itemstack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } } return itemstack; } public TileEntityChestHouse getChestInventory() { return this.chestInventory; } } TileEntity : package mysteriousdevs.spellp.tileentity; import mysteriousdevs.spellp.References; import mysteriousdevs.spellp.container.ContainerChestHouse; import net.minecraft.block.BlockEnderChest; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.inventory.Container; import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntityLockableLoot; import net.minecraft.util.ITickable; import net.minecraft.util.NonNullList; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; public class TileEntityChestHouse extends TileEntityLockableLoot implements ITickable { private NonNullList<ItemStack> chestContents = NonNullList.<ItemStack>withSize(72, ItemStack.EMPTY); public String owner = ""; public int numPlayersUsing, ticksSinceSync; public float lidAngle, prevLidAngle; @Override public int getSizeInventory() { return 72; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isEmpty() { for(ItemStack stack : this.chestContents) { if(!stack.isEmpty()) return false; } return true; } @Override public String getName() { return this.hasCustomName() ? this.customName : "container.chest_house"; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.chestContents = NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY); if(!this.checkLootAndRead(compound)) ItemStackHelper.loadAllItems(compound, chestContents); if(compound.hasKey("CustomName", 8)) this.customName = compound.getString("CustomName"); this.owner = compound.getString("Owner"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); if(!this.checkLootAndWrite(compound)) ItemStackHelper.saveAllItems(compound, chestContents); if(compound.hasKey("CustomName", 8)) compound.setString("CustomName", this.customName); compound.setString("Owner", this.owner); return compound; } @Override public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { return new ContainerChestHouse(playerInventory, this, playerIn); } @Override public String getGuiID() { return References.MODID + ":house_chest"; } @Override protected NonNullList<ItemStack> getItems() { return this.chestContents; } @Override public void update() { if (!this.world.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + pos.getX() + pos.getY() + pos.getZ()) % 200 == 0) { this.numPlayersUsing = 0; float f = 5.0F; for (EntityPlayer entityplayer : this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB((double)((float)pos.getX() - 5.0F), (double)((float)pos.getY() - 5.0F), (double)((float)pos.getZ() - 5.0F), (double)((float)(pos.getX() + 1) + 5.0F), (double)((float)(pos.getY() + 1) + 5.0F), (double)((float)(pos.getZ() + 1) + 5.0F)))) { if (entityplayer.openContainer instanceof ContainerChestHouse) { if (((ContainerChestHouse)entityplayer.openContainer).getChestInventory() == this) { ++this.numPlayersUsing; } } } } this.prevLidAngle = this.lidAngle; float f1 = 0.1F; if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F) { double d1 = (double)pos.getX() + 0.5D; double d2 = (double)pos.getZ() + 0.5D; this.world.playSound((EntityPlayer)null, d1, (double)pos.getY() + 0.5D, d2, SoundEvents.BLOCK_IRON_TRAPDOOR_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F); } if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) { float f2 = this.lidAngle; if (this.numPlayersUsing > 0) { this.lidAngle += 0.1F; } else { this.lidAngle -= 0.1F; } if (this.lidAngle > 1.0F) { this.lidAngle = 1.0F; } float f3 = 0.5F; if (this.lidAngle < 0.5F && f2 >= 0.5F) { double d3 = (double)pos.getX() + 0.5D; double d0 = (double)pos.getZ() + 0.5D; this.world.playSound((EntityPlayer)null, d3, (double)pos.getY() + 0.5D, d0, SoundEvents.BLOCK_IRON_TRAPDOOR_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F); } if (this.lidAngle < 0.0F) { this.lidAngle = 0.0F; } } } @Override public void openInventory(EntityPlayer player) { ++this.numPlayersUsing; this.world.addBlockEvent(pos, this.getBlockType(), 1, this.numPlayersUsing); this.world.notifyNeighborsOfStateChange(pos, this.getBlockType(), false); } @Override public void closeInventory(EntityPlayer player) { --this.numPlayersUsing; this.world.addBlockEvent(pos, this.getBlockType(), 1, this.numPlayersUsing); this.world.notifyNeighborsOfStateChange(pos, this.getBlockType(), false); } public String getOwner(){ return owner; } } GUI : package mysteriousdevs.spellp.gui; import mysteriousdevs.spellp.References; import mysteriousdevs.spellp.container.ContainerChestHouse; import mysteriousdevs.spellp.tileentity.TileEntityChestHouse; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import java.awt.*; public class GuiChestHouse extends GuiContainer { private static final ResourceLocation GUI_CHEST = new ResourceLocation(References.MODID + ":textures/gui/house_chest.png"); private final InventoryPlayer playerInventory; private final TileEntityChestHouse te; public GuiChestHouse(InventoryPlayer playerInventory, TileEntityChestHouse chestInventory, EntityPlayer player) { super(new ContainerChestHouse(playerInventory, chestInventory, player)); this.playerInventory = playerInventory; this.te = chestInventory; this.xSize = 179; this.ySize = 256; } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.fontRenderer.drawString(this.te.getDisplayName().getUnformattedText(), 8, 6, Color.WHITE.getRGB()); this.fontRenderer.drawString("Owner : " + te.owner, 100, 6, Color.WHITE.getRGB()); this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 92, Color.WHITE.getRGB()); } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); this.mc.getTextureManager().bindTexture(GUI_CHEST); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); } } Spectator Mode(Bug) : Creative Mode :
  4. The best for the image editing would be Photoshop but paint.net is good for a free software and for models the best is blockbench
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.