Jump to content

Forge modding 1.7.10 tile entity rotation not working


yorkeMC

Recommended Posts

Hello, I am working on a little mod with minecraftforge 1.7.10, in the mod I have a custom furnace used to make one of the tool materials. It is meant to rotate the way the player is facing when placed but this dosent work, and I cant find any tutorials on it anywhere... It would be awesome if someone could help me with this problem.

 

 

Block class

package com.jyorke.naturalpowers.blocks;

 

import java.util.Random;

 

import org.lwjgl.opengl.GL11;

 

import com.jyorke.naturalpowers.main;

import com.jyorke.naturalpowers.tile_entity.TileEntityNatureFurnace;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.block.Block;

import net.minecraft.block.BlockContainer;

import net.minecraft.block.BlockFurnace;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.tileentity.TileEntityFurnace;

import net.minecraft.util.IIcon;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

 

public class natureFurnace extends BlockContainer{

 

@SideOnly(Side.CLIENT)

private IIcon top;

@SideOnly(Side.CLIENT)

private IIcon front;

 

private static boolean isBurning;

private final boolean isBurning2;

private final Random random = new Random();

 

public natureFurnace(boolean isActive) {

super(Material.rock);

isBurning2 = isActive;

}

 

@SideOnly(Side.CLIENT)

public void registerBlockIcons(IIconRegister iconregister){

this.blockIcon = iconregister.registerIcon("naturalpowers:side");

this.front = iconregister.registerIcon(this.isBurning2 ? "naturalpowers:Active" : "naturalpowers:inactive");

this.top = iconregister.registerIcon("naturalpowers:top");

}

 

public IIcon getIcon(int side, int meta){

if(side == 1){

return top;

}else if(side == 3){

return front;

}else{

return this.blockIcon;

}

}

 

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){

player.openGui(main.modInstance, 0, world, x, y, z);

return true;

}

 

public Item getItemDropped(int par1, Random random, int par3){

return Item.getItemFromBlock(main.natureFurnace);

}

 

public Item getItem(World world, int par2, int par3, int par4){

return Item.getItemFromBlock(main.natureFurnace);

}

 

@SideOnly(Side.CLIENT)

public void onBlockAdded(World world, int x, int y, int z){

super.onBlockAdded(world, x, y, z);

this.direction(world, x, y, z);

}

 

private void direction(World world, int x, int y, int z){

if(!world.isRemote){

Block direction = world.getBlock(x, y, z -1);

Block direction1 = world.getBlock(x, y, z +1);

Block direction2 = world.getBlock(x -1, y, z);

Block direction3 = world.getBlock(x +1, y, z);

byte byte0 = 3;

 

if(direction.func_149730_j() && direction.func_149730_j()){

byte0 = 3;

}

if(direction1.func_149730_j() && direction1.func_149730_j()){

byte0 = 2;

}

if(direction2.func_149730_j() && direction2.func_149730_j()){

byte0 = 5;

}

if(direction3.func_149730_j() && direction3.func_149730_j()){

byte0 = 4;

}

 

world.setBlockMetadataWithNotify(x, y, z, byte0, 2);

}

 

}

 

public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack){

if(entity == null){

return;

}

TileEntityNatureFurnace tile = (TileEntityNatureFurnace) world.getTileEntity(x, y, z);

int direction = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

 

world.setBlockMetadataWithNotify(x, y, z, direction, 0);

 

if(direction == 0){

world.setBlockMetadataWithNotify(x, y, z, 2, 2);

}

if(direction == 1){

world.setBlockMetadataWithNotify(x, y, z, 5, 2);

}

if(direction == 2){

world.setBlockMetadataWithNotify(x, y, z, 3, 2);

}

if(direction == 3){

world.setBlockMetadataWithNotify(x, y, z, 4, 2);

}

 

if(itemstack.hasDisplayName()){

((TileEntityNatureFurnace) world.getTileEntity(x, y, z)).furnaceName(itemstack.getDisplayName());

}

}

 

 

public static void updateBlockState(boolean burning, World world, int x, int y, int z){

int direction = world.getBlockMetadata(x, y, z);

TileEntity tileentity = world.getTileEntity(x, y, z);

isBurning = true;

 

if(burning){

world.setBlock(x, y, z, main.natureFurnaceActive);

 

}else{

world.setBlock(x, y, z, main.natureFurnace);

}

 

isBurning = false;

world.setBlockMetadataWithNotify(x, y, z, direction, 2);

 

if(tileentity != null){

tileentity.validate();world.setTileEntity(x, y, z, tileentity);

}

}

 

public void breakBlock(World world, int x, int y, int z, Block block, int meta){

if(!isBurning){

TileEntityNatureFurnace tileentitynaturefurnace = (TileEntityNatureFurnace) world.getTileEntity(x, y, z);

if(tileentitynaturefurnace != null){

for(int i = 0; i < tileentitynaturefurnace.getSizeInventory(); ++i){

ItemStack itemstack = tileentitynaturefurnace.getStackInSlot(i);

 

if(itemstack != null){

float f = this.random.nextFloat() * 0.6F + 0.1F;

float f1 = this.random.nextFloat() * 0.6F + 0.1F;

float f2 = this.random.nextFloat() * 0.6F + 0.1F;

 

while(itemstack.stackSize > 0){

int j = this.random.nextInt(21) + 10;

 

if(j > itemstack.stackSize){

j = itemstack.stackSize;

}

 

itemstack.stackSize -= j;

EntityItem entityitem = new EntityItem(world, (double) ((float) x + f), (double) ((float)y + f1), (double) ((float) z + f2), new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));

 

if(itemstack.hasTagCompound()){

entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));

}

 

float f3 = 0.025F;

entityitem.motionX = (double) ((float) this.random.nextGaussian() * f3);

entityitem.motionY = (double) ((float) this.random.nextGaussian() * f3 + 0.1F);

entityitem.motionZ = (double) ((float) this.random.nextGaussian() * f3);

world.spawnEntityInWorld(entityitem);

 

 

}

}

}

world.func_147453_f(x, y, z, block);

}

}

super.breakBlock(world, x, y, z, block, meta);

}

 

@SideOnly(Side.CLIENT)

public void randomDisplayTick(World world, int x, int y, int z, Random random){

if(this.isBurning2){

int direction = world.getBlockMetadata(x, y, z);

 

float xx = (float) x + 0.5F, yy = (float) y + random.nextFloat() * 6.0F / 16.0F, zz = (float) z + 0.5F, xx2 = random.nextFloat() * 0.3F - 0.2F, zz2 = 0.5F;

 

 

if(direction == 4){

world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);

world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);

}else if(direction == 5){

world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);

world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);

}else if(direction == 3){

world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);

world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);

}else if(direction == 2){

world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);

world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);

}

}

}

 

@Override

public TileEntity createNewTileEntity(World world, int par2) {

return new TileEntityNatureFurnace();

}

}

 

 

 

 

Tile Entity Class

package com.jyorke.naturalpowers.tile_entity;

 

import com.jyorke.naturalpowers.main;

import com.jyorke.naturalpowers.blocks.natureFurnace;

import com.jyorke.naturalpowers.handler.natureFurnaceRecipes;

 

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.inventory.ISidedInventory;

import net.minecraft.item.Item;

import net.minecraft.item.ItemBlock;

import net.minecraft.item.ItemStack;

import net.minecraft.item.ItemTool;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.nbt.NBTTagList;

import net.minecraft.tileentity.TileEntity;

 

public class TileEntityNatureFurnace extends TileEntity implements ISidedInventory{

 

private static final int[] slotsTop = new int[] {0};

private static final int[] slotsBottom = new int[] {2, 1};

private static final int[] slotsSides = new int[] {1};

 

private ItemStack[] furnaceItemStacks = new ItemStack[3];

 

public int furnaceBurnTime;

public int currentBurnTime;

public int furnaceCookTime;

 

private String furnaceName;

public int direction;

 

public void furnaceName(String string){

this.furnaceName = string;

}

 

@Override

public int getSizeInventory() {

return this.furnaceItemStacks.length;

}

 

@Override

public ItemStack getStackInSlot(int slot) {

return this.furnaceItemStacks[slot];

}

 

@Override

public ItemStack decrStackSize(int par1, int par2) {

if (this.furnaceItemStacks[par1] != null) {

ItemStack itemstack;

if (this.furnaceItemStacks[par1].stackSize <= par2) {

itemstack = this.furnaceItemStacks[par1];

this.furnaceItemStacks[par1] = null;

return itemstack;

} else {

itemstack = this.furnaceItemStacks[par1].splitStack(par2);

 

if (this.furnaceItemStacks[par1].stackSize == 0) {

this.furnaceItemStacks[par1] = null;

}

return itemstack;

}

} else {

return null;

}

}

 

@Override

public ItemStack getStackInSlotOnClosing(int slot) {

if (this.furnaceItemStacks[slot] != null) {

ItemStack itemstack = this.furnaceItemStacks[slot];

this.furnaceItemStacks[slot] = null;

return itemstack;

} else {

return null;

}

}

 

@Override

public void setInventorySlotContents(int slot, ItemStack itemstack) {

this.furnaceItemStacks[slot] = itemstack;

 

if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) {

itemstack.stackSize = this.getInventoryStackLimit();

}

 

}

 

@Override

public String getInventoryName() {

return this.hasCustomInventoryName() ? this.furnaceName : "Nature Furnace";

}

 

@Override

public boolean hasCustomInventoryName() {

return this.furnaceName != null && this.furnaceName.length() > 0;

}

 

@Override

public int getInventoryStackLimit() {

return 64;

}

 

public void readFromNBT(NBTTagCompound tagCompound) {

super.readFromNBT(tagCompound);

NBTTagList tagList = tagCompound.getTagList("Items", 10);

this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];

 

for (int i = 0; i < tagList.tagCount(); ++i) {

NBTTagCompound tabCompound1 = tagList.getCompoundTagAt(i);

byte byte0 = tabCompound1.getByte("Slot");

 

if (byte0 >= 0 && byte0 < this.furnaceItemStacks.length) {

this.furnaceItemStacks[byte0] = ItemStack.loadItemStackFromNBT(tabCompound1);

}

}

 

this.furnaceBurnTime = tagCompound.getShort("BurnTime");

this.furnaceCookTime = tagCompound.getShort("CookTime");

this.currentBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);

 

if (tagCompound.hasKey("CustomName", 8)) {

this.furnaceName = tagCompound.getString("CustomName");

}

}

 

public void writeToNBT(NBTTagCompound tagCompound) {

super.writeToNBT(tagCompound);

tagCompound.setShort("BurnTime", (short) this.furnaceBurnTime);

tagCompound.setShort("CookTime", (short) this.furnaceBurnTime);

NBTTagList tagList = new NBTTagList();

 

for (int i = 0; i < this.furnaceItemStacks.length; ++i) {

if (this.furnaceItemStacks != null) {

NBTTagCompound tagCompound1 = new NBTTagCompound();

tagCompound1.setByte("Slot", (byte) i);

this.furnaceItemStacks.writeToNBT(tagCompound1);

tagList.appendTag(tagCompound1);

}

}

 

tagCompound.setTag("Items", tagList);

 

if (this.hasCustomInventoryName()) {

tagCompound.setString("CustomName", this.furnaceName);

}

}

 

@SideOnly(Side.CLIENT)

public int getCookProgressScaled(int par1) {

return this.furnaceCookTime * par1 / 200;

}

 

@SideOnly(Side.CLIENT)

public int getBurnTimeRemainingScaled(int par1) {

if (this.currentBurnTime == 0) {

this.currentBurnTime = 200;

}

 

return this.furnaceBurnTime * par1 / this.currentBurnTime;

}

 

public boolean isBurning() {

return this.furnaceBurnTime > 0;

}

 

public void updateEntity() {

boolean flag = this.furnaceBurnTime > 0;

boolean flag1 = false;

 

if (this.furnaceBurnTime > 0) {

--this.furnaceBurnTime;

}

 

if (!this.worldObj.isRemote) {

if (this.furnaceBurnTime == 0 && this.canSmelt()) {

this.currentBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);

 

if (this.furnaceBurnTime > 0) {

flag1 = true;

if (this.furnaceItemStacks[1] != null) {

--this.furnaceItemStacks[1].stackSize;

 

if (this.furnaceItemStacks[1].stackSize == 0) {

this.furnaceItemStacks[1] = furnaceItemStacks[1].getItem().getContainerItem(this.furnaceItemStacks[1]);

}

}

}

}

 

if (this.isBurning() && this.canSmelt()) {

++this.furnaceCookTime;

if (this.furnaceCookTime == 200) {

this.furnaceCookTime = 0;

this.smeltItem();

flag1 = true;

}

} else {

this.furnaceCookTime = 0;

}

}

 

if (flag != this.furnaceBurnTime > 0) {

flag1 = true;

natureFurnace.updateBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);

}

 

if (flag1) {

this.markDirty();

}

}

 

private boolean canSmelt() {

if (this.furnaceItemStacks[0] == null) {

return false;

} else {

ItemStack itemstack = natureFurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);

if (itemstack == null) return false;

if (this.furnaceItemStacks[2] == null) return true;

if (!this.furnaceItemStacks[2].isItemEqual(itemstack)) return false;

int result = furnaceItemStacks[2].stackSize + itemstack.stackSize;

return result <= getInventoryStackLimit() && result <= this.furnaceItemStacks[2].getMaxStackSize();

}

}

 

public void smeltItem() {

if (this.canSmelt()) {

ItemStack itemstack = natureFurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);

 

if (this.furnaceItemStacks[2] == null) {

this.furnaceItemStacks[2] = itemstack.copy();

} else if (this.furnaceItemStacks[2].getItem() == itemstack.getItem()) {

this.furnaceItemStacks[2].stackSize += itemstack.stackSize;

}

 

--this.furnaceItemStacks[0].stackSize;

 

if(this.furnaceItemStacks[0].stackSize == 0){

this.furnaceItemStacks[0] = null;

}

}

}

 

public static int getItemBurnTime(ItemStack itemstack){

if(itemstack == null){

return 0;

}else{

Item item = itemstack.getItem();

 

if(item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air){

Block block = Block.getBlockFromItem(item);

 

if(block == main.block1){

return 50;

 

}

}

 

if (item == main.CompoundFuel) return 50;

}

return GameRegistry.getFuelValue(itemstack);

}

 

public static boolean isItemFuel(ItemStack itemstack){

return getItemBurnTime(itemstack) > 0;

}

 

@Override

public boolean isUseableByPlayer(EntityPlayer player) {

return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D;

}

 

@Override

public void openInventory() {

 

}

 

@Override

public void closeInventory() {

 

}

 

@Override

public boolean isItemValidForSlot(int par1, ItemStack itemstack) {

return par1 == 2 ? false : (par1 == 1 ? isItemFuel(itemstack) : true);

}

 

@Override

public int[] getAccessibleSlotsFromSide(int par1) {

return par1 == 0 ? slotsBottom : (par1 == 1 ? slotsTop : slotsSides);

}

 

@Override

public boolean canInsertItem(int par1, ItemStack itemstack, int par3) {

return this.isItemValidForSlot(par1, itemstack);

}

 

@Override

public boolean canExtractItem(int par1, ItemStack itemstack, int par3) {

return par3 != 0 || par1 != 1 || itemstack.getItem() == Items.bucket;

}

 

}

 

 

 

 

 

 

ContainerClass

package com.jyorke.naturalpowers.inventory;

 

import com.jyorke.naturalpowers.handler.natureFurnaceRecipes;

import com.jyorke.naturalpowers.tile_entity.TileEntityNatureFurnace;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.player.InventoryPlayer;

import net.minecraft.inventory.Container;

import net.minecraft.inventory.ICrafting;

import net.minecraft.inventory.Slot;

import net.minecraft.inventory.SlotFurnace;

import net.minecraft.item.ItemStack;

 

public class ContainerNatureFurnace extends Container{

 

private TileEntityNatureFurnace tileFurnace;

private int lastCookTime;

private int lastBurnTime;

private int lastItemBurnTime;

 

public ContainerNatureFurnace(InventoryPlayer player, TileEntityNatureFurnace tileEntityFurnace){

this.tileFurnace = tileEntityFurnace;

this.addSlotToContainer(new Slot(tileEntityFurnace, 0, 56, 17));

this.addSlotToContainer(new Slot(tileEntityFurnace, 1, 56, 53));

this.addSlotToContainer(new SlotFurnace(player.player, tileEntityFurnace, 2, 116, 35));

int i;

 

for(i = 0; i < 3; ++i){

for(int j = 0; j < 9; ++j){

this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));

}

}

 

for(i = 0; i < 9; ++i){

this.addSlotToContainer(new Slot( player, i , 8 + i * 18, 142));

}

}

 

public void addCraftingToCrafters(ICrafting craft){

super.addCraftingToCrafters(craft);

craft.sendProgressBarUpdate(this, 0, this.tileFurnace.furnaceCookTime);

craft.sendProgressBarUpdate(this, 1, this.tileFurnace.furnaceBurnTime);

craft.sendProgressBarUpdate(this, 2, this.tileFurnace.currentBurnTime);

}

 

public void detectAndSendChanges(){

super.detectAndSendChanges();for(int i = 0; i < this.crafters.size(); ++i){

ICrafting craft = (ICrafting) this.crafters.get(i);

 

if(this.lastCookTime != this.tileFurnace.furnaceCookTime){

craft.sendProgressBarUpdate(this, 0, this.tileFurnace.furnaceCookTime);

}

 

if(this.lastBurnTime != this.tileFurnace.furnaceBurnTime){

craft.sendProgressBarUpdate(this, 1, this.tileFurnace.furnaceCookTime);

}

 

if(this.lastItemBurnTime != this.tileFurnace.currentBurnTime){

craft.sendProgressBarUpdate(this, 2, this.tileFurnace.currentBurnTime);

}

}

 

this.lastBurnTime = this.tileFurnace.furnaceBurnTime;

this.lastCookTime = this.tileFurnace.furnaceCookTime;

this.lastItemBurnTime = this.tileFurnace.currentBurnTime;

}

 

@SideOnly(Side.CLIENT)

public void updateProgressBar(int par1, int par2){

if(par1 == 0){

this.tileFurnace.furnaceCookTime = par2;

}

 

if(par1 == 1){

this.tileFurnace.furnaceBurnTime = par2;

}

 

if(par1 == 2){

this.tileFurnace.currentBurnTime = par2;

}

}

 

@Override

public boolean canInteractWith(EntityPlayer player) {

return this.tileFurnace.isUseableByPlayer(player);

}

 

public ItemStack transferStackInSlot(EntityPlayer player, int par2){

ItemStack itemstack = null;

Slot slot = (Slot) this.inventorySlots.get(par2);

 

if(slot != null && slot.getHasStack()){

ItemStack itemstack1 = slot.getStack();

itemstack = itemstack1.copy();

 

if(par2 == 2){

if(!this.mergeItemStack(itemstack1, 3, 39, true)){

return null;

}

slot.onSlotChange(itemstack1, itemstack);

}else if(par2 != 1 && par2 != 0){

if(natureFurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null){

if(!this.mergeItemStack(itemstack1, 0, 1, false)){

return null;

 

}

}else if(TileEntityNatureFurnace.isItemFuel(itemstack1)){

if(!this.mergeItemStack(itemstack1, 1, 2, false)){

return null;

}

}else if(par2 >=3 && par2 < 30){

if(!this.mergeItemStack(itemstack1, 30, 39, false)){

return null;

}

}else if(par2 >=30 && par2 < 39 && this.mergeItemStack(itemstack1, 3, 30, false)){

return null;

}

}else if(!this.mergeItemStack(itemstack1, 3, 39, false)){

return null;

}

if(itemstack1.stackSize == 0){

slot.putStack((ItemStack)null);

}else{

slot.onSlotChanged();

}

if(itemstack1.stackSize == itemstack.stackSize){

return null;

}

slot.onPickupFromSlot(player, itemstack1);

}

return itemstack;

}

}

 

 

 

 

while(awake)

{

    coffee++;

}

Link to comment
Share on other sites

Well your getIcon function doesn't seem to give a shit about the metadata.  Might want to fix that.

 

   public IIcon getIcon(int side, int meta){
      if(side == 1){
         return top;
      }else if(side == 3){ //cough cough, use metadata maybe?
         return front;
      }else{
         return this.blockIcon;
      }
   }

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
  • Topics

×
×
  • Create New...

Important Information

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