i am porting my mod to Minecraft 1.8 and I got an error on:
world.setBlockMetadataWithNotify(i, j, k, le, 3);
it says "The method setBlockMetadataWithNotify(int, int, int, int, int) is undefined for the type World"
if i use the Quickfix it looks like this:
((Object) world).setBlockMetadataWithNotify(i, j, k, le, 3);
and I don't know what I have to put instead of Object, google doesn't helped me....
I have the same problem with scheduleBlockUpdate I would be glad about help
here the Code:
public void onBlockAdded(World world, int i, int j, int k) {
Ok.... I still don't understand anything..... here is my current code:
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f, int i) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GL11.glRotatef(180, 0F, 0F, 1F);
BlockPos pos;
World world = this.getWorld();
IBlockState dir = world.getBlockState(pos);
GL11.glRotatef(dir * 90, 0.0F, 1.0F, 0.0F);
this.bindTexture(texture);
GL11.glPushMatrix();
this.model.renderModel(0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
Could anyone post me an example my English isn't the best and I can't understand all this currently,I am still getting error's and I am sure that 50% of the code are wrong
Oh and I get erro's on the TileEntitySpecialRenderer if I add the BlockPos to the renderTileEntityAt method
Ok I have changed now the stuff and I understand now how to get the BlockState(I have tought it would be more complicated ^^)
But I am getting this error:
The operator * is undefined for the argument type(s) IBlockState, int (at: "GL11.glRotatef(dir * 90, 0.0F, 1.0F, 0.0F);")
I Think i have set the BlockState wrong but I am not sure and google doesn't helps much....
so here's the code where I set the BlockState:
public void onBlockAdded(World world, BlockPos pos) {
EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
if (entity != null) {
int le = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
world.setBlockState(pos, DarkRoleplayBlockDungeonChest.blockDungeonChest.getDefaultState(),le);
}
world.scheduleUpdate(pos, this, this.tickRate(world));
}
Yes I have everything in one Class what is need for the Block here is the whole class:
package net.jtk.darkroleplay;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.*;
import net.minecraft.client.*;
import net.minecraft.entity.*;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.fml.*;
public class DarkRoleplayBlockDungeonChest extends BlockContainer {
public void onBlockAdded(World world, BlockPos pos) {
EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
if (entity != null) {
int le = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
world.setBlockState(pos, DarkRoleplayBlockDungeonChest.blockDungeonChest.getDefaultState(),le);
}
world.scheduleUpdate(pos, this, this.tickRate(world));
}
public static Block blockDungeonChest;
public static Object instance;
public DarkRoleplayBlockDungeonChest() {
super(Material.wood);
}
static {
blockDungeonChest = new DarkRoleplayBlockDungeonChest()
.setHardness(2.0F).setResistance(10.0F).setLightLevel(0.0F)
.setUnlocalizedName("blockDungeonChest")
.setStepSound(Block.soundTypeStone)
.setCreativeTab(DarkRoleplayTabs.drBlocksTab);
blockDungeonChest.setBlockBounds(1.0F / 16F * 1F, 0.0F,
1.0F / 16F * 1F, 1.0F / 16F * 15F, 1.0F / 16F * 12F,
1.0F / 16F * 15F);
}
public int getRenderType() {
return -1;
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityCustomDungeonChest();
}
public static void serverLoad(FMLServerStartingEvent event) {
}
public static void preInit(FMLPreInitializationEvent event) {
GameRegistry.registerBlock(blockDungeonChest, "blockDungeonChest");
}
}
class TileEntityCustomDungeonChest extends TileEntity {
}
class ItemRendererBlockDungeonChest implements IItemRenderer {
private ModelDungeonChest model;
public ItemRendererBlockDungeonChest() {
model = new ModelDungeonChest();
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
TileEntityRendererDispatcher.instance.renderTileEntityAt(
new TileEntityCustomDungeonChest(), 0.0D, 0.0D, 0.0D, 0.0F);
}
}
class customRendererDungeonChest extends TileEntitySpecialRenderer {
private static final ResourceLocation texture = new ResourceLocation(
DarkRoleplay.MODID, "textures/blockDungeonChest.png");
private ModelDungeonChest model;
public customRendererDungeonChest() {
this.model = new ModelDungeonChest();
}
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f, int i) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GL11.glRotatef(180, 0F, 0F, 1F);
BlockPos pos = tileentity.getPos();
World world = tileentity.getWorld();
IBlockState dir = world.getBlockState(pos);
GL11.glRotatef(dir * 90, 0.0F, 1.0F, 0.0F);
this.bindTexture(texture);
GL11.glPushMatrix();
this.model.renderModel(0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}
So to explain exactly what I want to do I want to save the direction(integer) the player is looking at placing the Block
and to get this integer at rendering the Model (I have tried also NBT for this but it doesn't work)
i am porting my mod to Minecraft 1.8 and I got an error on:
world.setBlockMetadataWithNotify(i, j, k, le, 3);
it says "The method setBlockMetadataWithNotify(int, int, int, int, int) is undefined for the type World"
if i use the Quickfix it looks like this:
((Object) world).setBlockMetadataWithNotify(i, j, k, le, 3);
and I don't know what I have to put instead of Object, google doesn't helped me....
I have the same problem with scheduleBlockUpdate I would be glad about help
here the Code:
EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
if (entity != null) {
int le = MathHelper
.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
BlockPos pos = null;
IBlockState newState = null;
((Object) world).setBlockMetadataWithNotify(i, j, k, le, 3);
}
((Object) world).scheduleBlockUpdate(i, j, k, this, this.tickRate(world));
}
(is there a better way to post code?)
I have currently no errors but I need to read the BlockState in the renderTileEnitytyat method.
And i cant find any Code I could use.
(Oh and setBlockMetadata is still existing thats why I used it)
Could anyone post me an example my English isn't the best and I can't understand all this currently,I am still getting error's and I am sure that 50% of the code are wrong
Oh and I get erro's on the TileEntitySpecialRenderer if I add the BlockPos to the renderTileEntityAt method
But I am getting this error:
The operator * is undefined for the argument type(s) IBlockState, int (at: "GL11.glRotatef(dir * 90, 0.0F, 1.0F, 0.0F);")
I Think i have set the BlockState wrong but I am not sure and google doesn't helps much....
so here's the code where I set the BlockState:
and to get this integer at rendering the Model (I have tried also NBT for this but it doesn't work)