Commit 544446ec authored by mrAppleXZ's avatar mrAppleXZ 💾

Few fixes, the Stone Crusher is still broken

parent 97da6383
......@@ -222,6 +222,10 @@ public class GuiMicroscopeResearch extends GuiAbstractMicroscope
{
int col = x / buttSize;
int row = y / buttSize;
if(row >= current.length)
return;
if(col >= current[0].length)
return;
if(!checkPos || (prevC != col || prevR != row))
{
prevC = col;
......
......@@ -40,12 +40,12 @@ public class TESRMagibench extends PXLFastTESR<TileMagibench>
{
GlStateManager.pushMatrix();
GlStateManager.scale(0.8f, 0.8f, 0.8f);
GlStateManager.translate(0.1f, 0, 0.1f);
GlStateManager.translate(0.1f, -0.03f, 0.1f);
GlStateManager.scale(scale, scale, scale);
GlStateManager.translate(t.getWidth() - xx - 1, 0, t.getHeight() - yy - 1);
if (!(stack.getItem() instanceof ItemBlock))
{
GlStateManager.translate(0, -0.22f, 0);
GlStateManager.translate(0, -0.2f, 0);
GlStateManager.rotate(90, 1, 0, 0);
}
Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.FIXED);
......
......@@ -20,7 +20,6 @@ import ru.pearx.lib.math.MathUtils;
import ru.pearx.libmc.PXLMC;
import ru.pearx.libmc.client.ModelSupplied;
import ru.pearx.libmc.client.TESRMultiblock;
import ru.pearx.libmc.client.gui.controls.common.BlockArrayShowcase;
import ru.pearx.libmc.client.models.PXLModelRenderer;
import ru.pearx.purmag.common.Utils;
import ru.pearx.purmag.common.tiles.TileStoneCrusher;
......@@ -60,10 +59,10 @@ public class TESRStoneCrusher extends TESRMultiblock<TileStoneCrusher>
tes.draw();
GlStateManager.popMatrix();
long timeDelta = te.getWorld().getTotalWorldTime() - te.getPreviousSpin();
long timeDelta = te.getWorld().getTotalWorldTime() - te.getPreviousAction();
float deltaCooldown = (float) timeDelta / te.getCooldownBetweenSpins();
{
float rot = te.getSpins() * 90 + (timeDelta > te.getCooldownBetweenSpins() ? 0 : -90 + 90 * deltaCooldown);
float rot = timeDelta > te.getCooldownBetweenSpins() ? te.getSpins() * 90 : te.getPreviousSpins() * 90 + (te.getSpins() - te.getPreviousSpins()) * 90 * deltaCooldown;
//handle
GlStateManager.pushMatrix();
......@@ -88,10 +87,10 @@ public class TESRStoneCrusher extends TESRMultiblock<TileStoneCrusher>
{
float os = 1f / te.getMaxSpins();
boolean onGround = te.getSpins() <= 0;
boolean onGround = timeDelta > te.getCooldownBetweenSpins() && te.getSpins() <= 0;
float anvilX = 1;
float anvilY = te.getSpins() * os + (timeDelta > te.getCooldownBetweenSpins() ? 0 : -os + os * deltaCooldown);
float anvilY = timeDelta > te.getCooldownBetweenSpins() ? te.getSpins() * os : te.getPreviousSpins() * os + (te.getSpins() - te.getPreviousSpins()) * os * deltaCooldown;
if (!onGround)
{
......
package ru.pearx.purmag.common.blocks.base;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
......@@ -10,6 +11,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import ru.pearx.purmag.PurMag;
import ru.pearx.purmag.common.blocks.base.BlockBase;
......
......@@ -7,6 +7,9 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import ru.pearx.libmc.common.ItemStackUtils;
......@@ -33,20 +36,35 @@ public class TileStoneCrusher extends TilePMMultiblockMaster
}
};
@SideOnly(Side.CLIENT)
private int previousSpins;
@SideOnly(Side.CLIENT)
public int getPreviousSpins()
{
return previousSpins;
}
@SideOnly(Side.CLIENT)
public void setPreviousSpins(int previousSpins)
{
this.previousSpins = previousSpins;
}
private int crushes;
private int spins;
private long previousSpin;
private long previousAction;
public int getCrushes()
{
return crushes;
}
public void setCrushes(int crushes, boolean sync)
public void setCrushes(int crushes, boolean sync, EntityPlayer p)
{
this.crushes = crushes;
if(sync)
sendUpdates(new NBTTagCompoundBuilder().setInteger("crushes", crushes).build(), null);
sendUpdates(new NBTTagCompoundBuilder().setInteger("crushes", crushes).build(), p);
}
public int getSpins()
......@@ -66,21 +84,23 @@ public class TileStoneCrusher extends TilePMMultiblockMaster
public void setSpins(int spins, boolean sync, EntityPlayer p)
{
if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT && getWorld().isRemote)
setPreviousSpins(getSpins());
this.spins = spins;
if(sync)
sendUpdates(new NBTTagCompoundBuilder().setInteger("spins", spins).build(), p);
}
public long getPreviousSpin()
public long getPreviousAction()
{
return previousSpin;
return previousAction;
}
public void setPreviousSpin(long previousSpin, boolean sync, EntityPlayer p)
{
this.previousSpin = previousSpin;
this.previousAction = previousSpin;
if(sync)
sendUpdates(new NBTTagCompoundBuilder().setLong("previousSpin", previousSpin).build(), p);
sendUpdates(new NBTTagCompoundBuilder().setLong("previousAction", previousSpin).build(), p);
}
@Override
......@@ -90,11 +110,11 @@ public class TileStoneCrusher extends TilePMMultiblockMaster
if (tag.hasKey("items", Constants.NBT.TAG_COMPOUND))
handler.deserializeNBT((NBTTagCompound) tag.getTag("items"));
if(tag.hasKey("crushes", Constants.NBT.TAG_INT))
setCrushes(tag.getInteger("crushes"), false);
setCrushes(tag.getInteger("crushes"), false, null);
if(tag.hasKey("spins", Constants.NBT.TAG_INT))
setSpins(tag.getInteger("spins"), false, null);
if(tag.hasKey("previousSpin", Constants.NBT.TAG_LONG))
setPreviousSpin(tag.getLong("previousSpin"), false, null);
if(tag.hasKey("previousAction", Constants.NBT.TAG_LONG))
setPreviousSpin(tag.getLong("previousAction"), false, null);
}
@Override
......@@ -104,6 +124,7 @@ public class TileStoneCrusher extends TilePMMultiblockMaster
tag.setTag("items", handler.serializeNBT());
tag.setInteger("crushes", getCrushes());
tag.setInteger("spins", getSpins());
tag.setLong("previousAction", getPreviousAction());
}
@Override
......@@ -121,8 +142,6 @@ public class TileStoneCrusher extends TilePMMultiblockMaster
return super.getCapability(capability, facing);
}
@Override
public boolean handleActivated(MultiblockActivatedEvent evt, IMultiblockPart part)
{
......@@ -130,7 +149,7 @@ public class TileStoneCrusher extends TilePMMultiblockMaster
BlockPos original = getOriginalPos(part.getPos());
if (MultiblockRegistry.STONE_CRUSHER.handle.equals(original))
{
long delta = part.getWorld().getTotalWorldTime() - getPreviousSpin();
long delta = part.getWorld().getTotalWorldTime() - getPreviousAction();
if (getSpins() < getMaxSpins() && (delta < 0 || delta > getCooldownBetweenSpins()))
{
setSpins(getSpins() + 1, true, evt.getPlayer());
......@@ -141,7 +160,13 @@ public class TileStoneCrusher extends TilePMMultiblockMaster
//drop the anvil
else if (MultiblockRegistry.STONE_CRUSHER.lever.equals(original))
{
if(getSpins() > 0)
{
setCrushes(getCrushes() + getSpins(), true, evt.getPlayer());
setSpins(0, true, evt.getPlayer());
setPreviousSpin(part.getWorld().getTotalWorldTime(), true, evt.getPlayer());
return true;
}
}
//insert the item
else if(MultiblockRegistry.STONE_CRUSHER.anvil.equals(original) && getSpins() > 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment