Skip to content

Commit

Permalink
Merge pull request #1005 from malte0811/misc
Browse files Browse the repository at this point in the history
Misc fixes
  • Loading branch information
BluSunrize committed Mar 12, 2016
2 parents 05b2cb3 + f936cab commit 4f4faf4
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,12 @@ public void onLoad(WorldEvent.Load event)
for(Object render : RenderManager.instance.entityRenderMap.values())
if(RenderMinecart.class.isAssignableFrom(render.getClass()))
{
ModelMinecart wrapped = ObfuscationReflectionHelper.getPrivateValue(RenderMinecart.class, (RenderMinecart) render, "field_77013_a", "modelMinecart");
ObfuscationReflectionHelper.setPrivateValue(RenderMinecart.class,(RenderMinecart)render, (ModelMinecart)new ModelShaderMinecart(wrapped), "field_77013_a","modelMinecart");
Object o = ObfuscationReflectionHelper.getPrivateValue(RenderMinecart.class, (RenderMinecart) render, "field_77013_a", "modelMinecart");
if (o instanceof ModelMinecart)
{
ModelMinecart wrapped = (ModelMinecart) o;
ObfuscationReflectionHelper.setPrivateValue(RenderMinecart.class, (RenderMinecart) render, (ModelMinecart) new ModelShaderMinecart(wrapped), "field_77013_a", "modelMinecart");
}
}
ModelShaderMinecart.rendersReplaced = true;
}
Expand Down Expand Up @@ -256,7 +260,7 @@ public void onWorldTick(WorldTickEvent event)
{
synchronized (ItemDrill.animationTimer)
{
for (String name:ItemDrill.animationTimer.keySet())
for (String name:((Map<String, Integer>)ItemDrill.animationTimer).keySet())
{
Integer timer = ItemDrill.animationTimer.get(name);
timer--;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ public boolean hasContainerItem(ItemStack stack)
return true;
}
@Override
public boolean hasContainerItem()
{
return true;
}
@Override
public ItemStack getContainerItem(ItemStack stack)
{
return stack.getItemDamage()%2==0?new ItemStack(Items.glass_bottle): new ItemStack(Items.bucket);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ else if(this.blockMaterial==Material.wood||this.blockMaterial==Material.cactus)
@Override
public int getLightOpacity(IBlockAccess world, int x, int y, int z)
{
if (!(world instanceof World))
return 255;
World w = (World) world;
if (!w.blockExists(x, y, z))
return 255;
int meta = world.getBlockMetadata(x,y,z);
if(meta>=0&&meta<this.lightOpacities.length)
return this.lightOpacities[meta];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,23 @@ else if(pos!=0 && pos!=2 && pos<20 && (pos>9?(pos%5!=0&&pos%5!=4):true))
}
else if(pos==25)
return new float[]{fl==5?.5f:0,0,fl==3?.5f:0, fl==4?.5f:1,1,fl==2?.5f:1};
else if (pos==40||pos==44)
{
if (pos==44)
fl+=(fl%2==0?1:-1);
return new float[]{fl==3?.125f:(fl==2?.625f:0),.125f,fl==4?.125f:(fl==5?.625f:0), fl==2?.875f:(fl==3?.375f:1),0.375F,fl==5?.875f:(fl==4?.375f:1)};
}
else if(pos<50)
{
if(pos%5==0)
return new float[]{fw==3?.125f:0,0,fw==4?.125f:0, fw==2?.875f:1,pos%25/5==3?.5f:1,fw==5?.875f:1};
else if(pos%5==4)
return new float[]{fw==2?.125f:0,0,fw==5?.125f:0, fw==3?.875f:1,pos%25/5==3?.5f:1,fw==4?.875f:1};
else
else if (pos==43)
return new float[]{fl==4||fl==3?0:.125f, 0.5f,fl==2||fl==4?0:.125f, fl==5||fl==2?1:.875f,1,fl==3||fl==5?1:.875f};
else if (pos==41)
return new float[]{fl==3||fl==4?0:.125f, 0.5f,fl==2||fl==5?0:.125f, fl==2||fl==5?1:.875f,1,fl==4||fl==3?1:.875f};
else if (pos>48||pos<46)
return new float[]{0,.5f,0 ,1,1,1};
}
else if(pos<75)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ public void updateEntity()
{
if(offset[0]!=0||offset[1]!=0)
return;
if(
// !(worldObj.getBlock(xCoord-(facing<=3?2:0), yCoord+2, zCoord-(facing<=3?0:2)).isReplaceable(worldObj, xCoord-(facing<=3?2:0), yCoord+2, zCoord-(facing<=3?0:2)))
// || !(worldObj.getBlock(xCoord+(facing<=3?2:0), yCoord+2, zCoord+(facing<=3?0:2)).isReplaceable(worldObj, xCoord+(facing<=3?2:0), yCoord+2, zCoord+(facing<=3?0:2)))
// || !(worldObj.getBlock(xCoord-(facing<=3?2:0), yCoord-2, zCoord-(facing<=3?0:2)).isReplaceable(worldObj, xCoord-(facing<=3?2:0), yCoord-2, zCoord-(facing<=3?0:2)))
// || !(worldObj.getBlock(xCoord+(facing<=3?2:0), yCoord-2, zCoord+(facing<=3?0:2)).isReplaceable(worldObj, xCoord+(facing<=3?2:0), yCoord-2, zCoord+(facing<=3?0:2))))
isBlocked())
if(isBlocked())
{
canTurn=false;
return;
Expand All @@ -48,17 +43,13 @@ public void updateEntity()
prevRotation = rotation;

ForgeDirection fd = ForgeDirection.getOrientation(facing);
if(worldObj.getTileEntity(xCoord-fd.offsetX,yCoord,zCoord-fd.offsetZ) instanceof TileEntityDynamo)
if(worldObj.getTileEntity(xCoord-fd.offsetX,yCoord,zCoord-fd.offsetZ) instanceof TileEntityDynamo&&!multiblock)
{
double power = getPower();
int l=1;
TileEntity tileEntity = worldObj.getTileEntity(xCoord+fd.offsetX*l,yCoord,zCoord+fd.offsetZ*l);
while (l<3
&& tileEntity instanceof TileEntityWatermill
&& ((TileEntityWatermill)tileEntity).offset[0]==0
&& ((TileEntityWatermill)tileEntity).offset[1]==0
&& ( ((TileEntityWatermill)tileEntity).facing==facing || ((TileEntityWatermill)tileEntity).facing==ForgeDirection.OPPOSITES[facing] )
&& !((TileEntityWatermill)tileEntity).isBlocked())
&& canUse(tileEntity))
{
power += ((TileEntityWatermill)tileEntity).getPower();
l++;
Expand Down Expand Up @@ -101,6 +92,18 @@ else if(!multiblock)
multiblock=false;
}

private boolean canUse(TileEntity tileEntity)
{
if (!(tileEntity instanceof TileEntityWatermill))
return false;
TileEntityWatermill wm = (TileEntityWatermill) tileEntity;
return wm.offset[0]==0
&& wm.offset[1]==0
&& ( wm.facing==facing || wm.facing==ForgeDirection.OPPOSITES[facing] )
&& !wm.isBlocked()
&& !wm.multiblock;
}

public boolean isBlocked()
{
for(ForgeDirection fdY : new ForgeDirection[]{ForgeDirection.UP,ForgeDirection.DOWN})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public boolean checkArea()
return false;
}

int blocked = 0;
for(int hh=-6;hh<=6;hh++)
{
int blocked = 0;
int r=Math.abs(hh)==6?1: Math.abs(hh)==5?3: Math.abs(hh)==4?4: Math.abs(hh)>1?5: 6;
for(int ww=-r;ww<=r;ww++)
{
Expand All @@ -95,18 +95,20 @@ public boolean checkArea()
else if(worldObj.getTileEntity(xx,yy,zz) instanceof TileEntityWindmill)
{
blocked+=20;
turnSpeed++;
turnSpeed-=180;
turnSpeed-=179;
}
else
{
blocked++;
turnSpeed-=2;
}
}
}
if(blocked>100)
return false;
else if(blocked>50)
return true;
}
if (turnSpeed<=0)
return false;

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,13 +525,13 @@ public static ItemStack addToOccupiedSlot(IInventory inventory, int slot, ItemSt
if (stack.stackSize + existingStack.stackSize > stackLimit) {
int stackDiff = stackLimit - existingStack.stackSize;
existingStack.stackSize = stackLimit;
stack.stackSize -= stackDiff;
stack = copyStackWithAmount(stack, stack.stackSize-stackDiff);
inventory.setInventorySlotContents(slot, existingStack);
return stack;
}
existingStack.stackSize += Math.min(stack.stackSize, stackLimit);
inventory.setInventorySlotContents(slot, existingStack);
return stackLimit >= stack.stackSize ? null : stack.splitStack(stack.stackSize - stackLimit);
return null;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ public static void addRecipe(IItemStack output, IIngredient input, int energy, @
{
Object oInput = MTHelper.toObject(input);
if(oInput==null)
{
MineTweakerAPI.getLogger().logError("Did not add crusher recipe for "+output.getDisplayName()+", input was null");
return;
}

CrusherRecipe r = new CrusherRecipe(MTHelper.toStack(output), oInput, energy);
if(r.input==null)
{
MineTweakerAPI.getLogger().logError("Did not add crusher recipe for "+output.getDisplayName()+", converted input was null");
return;
}
if(secondaryOutput!=null)
r.addToSecondaryOutput(MTHelper.toStack(secondaryOutput), (float)secondaryChance);
MineTweakerAPI.apply(new Add(r));
Expand Down

0 comments on commit 4f4faf4

Please sign in to comment.