mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 02:37:27 +00:00
Fixed scripted block not switching or being hidden correctly
This commit is contained in:
1 parent
5a84ed47d9
commit
2e5723033e
2 files changed
+45
-14
No files matched your search
@@ -19,6 +19,7 @@ import net.minecraft.world.chunk.Chunk;
|
||||
import noppes.npcs.*;
|
||||
import noppes.npcs.api.IBlock;
|
||||
import noppes.npcs.api.block.ITextPlane;
|
||||
import noppes.npcs.client.renderer.blocks.BlockScriptedRenderer;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
@@ -49,6 +50,7 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
|
||||
|
||||
public ItemStack itemModel = new ItemStack(CustomItems.scripted);
|
||||
public Block blockModel = null;
|
||||
private boolean hideModel;
|
||||
private int metadata;
|
||||
|
||||
public boolean needsClientUpdate = false;
|
||||
@@ -233,6 +235,21 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
|
||||
needsClientUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
boolean markForUpdate = false;
|
||||
boolean prevHideModel = this.hideModel;
|
||||
boolean hideModel = BlockScriptedRenderer.overrideModel();
|
||||
|
||||
if (hideModel != prevHideModel) {
|
||||
this.hideModel = hideModel;
|
||||
markForUpdate = true;
|
||||
}
|
||||
|
||||
if (markForUpdate) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -240,11 +257,22 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
|
||||
handleUpdateTag(pkt.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldRenderInPass(int arg0) {
|
||||
if (blockModel != null && blockModel.isOpaqueCube()
|
||||
&& !BlockScriptedRenderer.overrideModel()) {
|
||||
return true;
|
||||
}
|
||||
return super.shouldRenderInPass(arg0);
|
||||
}
|
||||
|
||||
public void handleUpdateTag(NBTTagCompound tag){
|
||||
int light = lightValue;
|
||||
setDisplayNBT(tag);
|
||||
if(light != lightValue)
|
||||
checkLight(worldObj,xCoord,yCoord,zCoord);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public boolean checkLight(World world, int x, int y, int z)
|
||||
@@ -281,10 +309,8 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
|
||||
if(NoppesUtilPlayer.compareItems(item, itemModel, false, false) && b != blockModel)
|
||||
return;
|
||||
|
||||
boolean blockChanged = b != blockModel;
|
||||
int meta = item.getItemDamage();
|
||||
metadata = (meta == 0 || meta == metadata) && blockChanged ? metadata + 1 : meta;
|
||||
this.blockMetadata = metadata;
|
||||
metadata = item.getItemDamage();
|
||||
blockMetadata = metadata;
|
||||
|
||||
itemModel = item;
|
||||
blockModel = b;
|
||||
@@ -421,6 +447,11 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
|
||||
return this.customTileData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
}
|
||||
|
||||
public class TextPlane implements ITextPlane {
|
||||
public boolean textHasChanged = true;
|
||||
public TextBlock textBlock;
|
||||
|
||||
@@ -9,7 +9,6 @@ import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.src.FMLRenderAccessLibrary;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -51,6 +50,9 @@ public class BlockScriptedRenderer extends BlockRendererInterface{
|
||||
tile.renderFullBlock = true;
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
} else {
|
||||
renderer.renderStandardBlock(CustomItems.scripted, x, y, z);
|
||||
tile.renderFullBlock = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -63,22 +65,20 @@ public class BlockScriptedRenderer extends BlockRendererInterface{
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks) {
|
||||
TileScripted tile = (TileScripted) te;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glTranslatef((float) (x + 0.5), (float) y, (float) (z + 0.5));
|
||||
if (overrideModel()) {
|
||||
GL11.glTranslatef(0, 0.5F, 0);
|
||||
} else if (!tile.renderFullBlock) {
|
||||
if (!tile.renderFullBlock) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glTranslatef((float) (x + 0.5), (float) y, (float) (z + 0.5));
|
||||
GL11.glRotatef(tile.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(tile.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(tile.rotationZ, 0, 0, 1);
|
||||
GL11.glScalef(tile.scaleX, tile.scaleY, tile.scaleZ);
|
||||
GL11.glTranslatef(0, 0.5F, 0);
|
||||
renderItem(te, tile.itemModel);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (!tile.text1.text.isEmpty()) {
|
||||
drawText(tile.text1, x, y, z);
|
||||
@@ -183,7 +183,7 @@ public class BlockScriptedRenderer extends BlockRendererInterface{
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private boolean overrideModel() {
|
||||
public static boolean overrideModel() {
|
||||
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
|
||||
if (held == null)
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user