Added solderer particles, fixes #923
This commit is contained in:
@@ -20,7 +20,7 @@ import javax.annotation.Nonnull;
|
||||
public class NetworkNodeSolderer extends NetworkNode {
|
||||
public static final String ID = "solderer";
|
||||
|
||||
private static final String NBT_WORKING = "Working";
|
||||
public static final String NBT_WORKING = "Working";
|
||||
private static final String NBT_PROGRESS = "Progress";
|
||||
|
||||
private ItemHandlerBasic items = new ItemHandlerBasic(3, new ItemHandlerListenerNetworkNode(this)) {
|
||||
@@ -48,6 +48,7 @@ public class NetworkNodeSolderer extends NetworkNode {
|
||||
private ISoldererRecipe recipe;
|
||||
|
||||
private boolean working = false;
|
||||
private boolean wasWorking = false;
|
||||
private int progress = 0;
|
||||
|
||||
public NetworkNodeSolderer(INetworkNodeHolder holder) {
|
||||
@@ -63,6 +64,12 @@ public class NetworkNodeSolderer extends NetworkNode {
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (wasWorking != working) {
|
||||
wasWorking = working;
|
||||
|
||||
RSUtils.updateBlock(holder.world(), holder.pos());
|
||||
}
|
||||
|
||||
if (network == null) {
|
||||
return;
|
||||
}
|
||||
@@ -139,6 +146,7 @@ public class NetworkNodeSolderer extends NetworkNode {
|
||||
|
||||
if (tag.hasKey(NBT_WORKING)) {
|
||||
working = tag.getBoolean(NBT_WORKING);
|
||||
wasWorking = working;
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_PROGRESS)) {
|
||||
|
||||
@@ -9,11 +9,15 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockSolderer extends BlockNode {
|
||||
public BlockSolderer() {
|
||||
@@ -51,6 +55,48 @@ public class BlockSolderer extends BlockNode {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileSolderer && ((TileSolderer) tile).isWorking()) {
|
||||
EnumFacing direction = getActualState(state, world, pos).getValue(DIRECTION);
|
||||
|
||||
double x = 0;
|
||||
double y = (double) pos.getY() + 0.6D + rand.nextDouble() / 32F;
|
||||
double z = 0;
|
||||
|
||||
if (direction == EnumFacing.NORTH) {
|
||||
x = (double) pos.getX() + 0.4D;
|
||||
z = (double) pos.getZ() + 0.4D;
|
||||
} else if (direction == EnumFacing.EAST) {
|
||||
x = (double) pos.getX() + 0.6D;
|
||||
z = (double) pos.getZ() + 0.4D;
|
||||
} else if (direction == EnumFacing.SOUTH) {
|
||||
x = (double) pos.getX() + 0.6D;
|
||||
z = (double) pos.getZ() + 0.6D;
|
||||
} else if (direction == EnumFacing.WEST) {
|
||||
x = (double) pos.getX() + 0.4D;
|
||||
z = (double) pos.getZ() + 0.6D;
|
||||
}
|
||||
|
||||
int particles = rand.nextInt(5);
|
||||
|
||||
for (int i = 0; i < 1 + particles; ++i) {
|
||||
world.spawnParticle(
|
||||
EnumParticleTypes.SMOKE_NORMAL,
|
||||
x + (rand.nextDouble() / 16F * (rand.nextBoolean() ? 1 : -1)),
|
||||
y,
|
||||
z + (rand.nextDouble() / 16F * (rand.nextBoolean() ? 1 : -1)),
|
||||
0.0D,
|
||||
0.0D,
|
||||
0.0D
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.tile;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSolderer;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@@ -33,6 +34,8 @@ public class TileSolderer extends TileNode<NetworkNodeSolderer> {
|
||||
}
|
||||
});
|
||||
|
||||
private boolean working;
|
||||
|
||||
public TileSolderer() {
|
||||
dataManager.addWatchedParameter(DURATION);
|
||||
dataManager.addWatchedParameter(PROGRESS);
|
||||
@@ -53,6 +56,28 @@ public class TileSolderer extends TileNode<NetworkNodeSolderer> {
|
||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeUpdate(NBTTagCompound tag) {
|
||||
super.writeUpdate(tag);
|
||||
|
||||
tag.setBoolean(NetworkNodeSolderer.NBT_WORKING, getNode().isWorking());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readUpdate(NBTTagCompound tag) {
|
||||
super.readUpdate(tag);
|
||||
|
||||
if (tag.hasKey(NetworkNodeSolderer.NBT_WORKING)) {
|
||||
working = tag.getBoolean(NetworkNodeSolderer.NBT_WORKING);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWorking() {
|
||||
return working;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public NetworkNodeSolderer createNode() {
|
||||
|
||||
Reference in New Issue
Block a user