Added solderer particles, fixes #923

This commit is contained in:
raoulvdberge
2017-02-02 19:28:59 +01:00
parent 5cca4a4dc6
commit 9b298c25c7
4 changed files with 87 additions and 1 deletions

View File

@@ -36,6 +36,8 @@
- Updated Chinese translation (TartaricAcid) - Updated Chinese translation (TartaricAcid)
- Added filtering slots for the Crafting Monitor (raoulvdberge) - Added filtering slots for the Crafting Monitor (raoulvdberge)
- Added way to hide tasks created in an automated way in the Crafting Monitor (raoulvdberge) - Added way to hide tasks created in an automated way in the Crafting Monitor (raoulvdberge)
- Added Grid sorting by ID (way2muchnoise)
- Added Solderer particles (raoulvdberge)
### 1.3.5 ### 1.3.5
- Fixed TPS lag on very large crafting tasks (way2muchnoise) - Fixed TPS lag on very large crafting tasks (way2muchnoise)
@@ -83,6 +85,11 @@
- Removed IC2 support (raoulvdberge) - Removed IC2 support (raoulvdberge)
- Removed MCMultiPart support (will be re-added as soon as MCMultiPart for MC 1.11 is available) (raoulvdberge) - Removed MCMultiPart support (will be re-added as soon as MCMultiPart for MC 1.11 is available) (raoulvdberge)
### 1.2.20
- Fixed client side crash with cables (raoulvdberge)
- Added Solderer particles (raoulvdberge)
- Added Grid sorting by ID (way2muchnoise)
### 1.2.19 ### 1.2.19
- Added integration for Collosal Chests for the External Storage, Importer and Exporter improving performance (way2muchnoise) - Added integration for Collosal Chests for the External Storage, Importer and Exporter improving performance (way2muchnoise)
- Exposed the Network Card inventory of the Network Transmitter so other tiles can interact with it (raoulvdberge) - Exposed the Network Card inventory of the Network Transmitter so other tiles can interact with it (raoulvdberge)

View File

@@ -20,7 +20,7 @@ import javax.annotation.Nonnull;
public class NetworkNodeSolderer extends NetworkNode { public class NetworkNodeSolderer extends NetworkNode {
public static final String ID = "solderer"; 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 static final String NBT_PROGRESS = "Progress";
private ItemHandlerBasic items = new ItemHandlerBasic(3, new ItemHandlerListenerNetworkNode(this)) { private ItemHandlerBasic items = new ItemHandlerBasic(3, new ItemHandlerListenerNetworkNode(this)) {
@@ -48,6 +48,7 @@ public class NetworkNodeSolderer extends NetworkNode {
private ISoldererRecipe recipe; private ISoldererRecipe recipe;
private boolean working = false; private boolean working = false;
private boolean wasWorking = false;
private int progress = 0; private int progress = 0;
public NetworkNodeSolderer(INetworkNodeHolder holder) { public NetworkNodeSolderer(INetworkNodeHolder holder) {
@@ -63,6 +64,12 @@ public class NetworkNodeSolderer extends NetworkNode {
public void update() { public void update() {
super.update(); super.update();
if (wasWorking != working) {
wasWorking = working;
RSUtils.updateBlock(holder.world(), holder.pos());
}
if (network == null) { if (network == null) {
return; return;
} }
@@ -139,6 +146,7 @@ public class NetworkNodeSolderer extends NetworkNode {
if (tag.hasKey(NBT_WORKING)) { if (tag.hasKey(NBT_WORKING)) {
working = tag.getBoolean(NBT_WORKING); working = tag.getBoolean(NBT_WORKING);
wasWorking = working;
} }
if (tag.hasKey(NBT_PROGRESS)) { if (tag.hasKey(NBT_PROGRESS)) {

View File

@@ -9,11 +9,15 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List; import java.util.List;
import java.util.Random;
public class BlockSolderer extends BlockNode { public class BlockSolderer extends BlockNode {
public BlockSolderer() { public BlockSolderer() {
@@ -51,6 +55,48 @@ public class BlockSolderer extends BlockNode {
return true; 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 @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean isOpaqueCube(IBlockState state) { public boolean isOpaqueCube(IBlockState state) {

View File

@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSolderer; import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSolderer;
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer; import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter; import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
@@ -33,6 +34,8 @@ public class TileSolderer extends TileNode<NetworkNodeSolderer> {
} }
}); });
private boolean working;
public TileSolderer() { public TileSolderer() {
dataManager.addWatchedParameter(DURATION); dataManager.addWatchedParameter(DURATION);
dataManager.addWatchedParameter(PROGRESS); dataManager.addWatchedParameter(PROGRESS);
@@ -53,6 +56,28 @@ public class TileSolderer extends TileNode<NetworkNodeSolderer> {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); 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 @Override
@Nonnull @Nonnull
public NetworkNodeSolderer createNode() { public NetworkNodeSolderer createNode() {