Single component panels work, fixed some bugs with normal ones
This commit is contained in:
parent
bd26b2b358
commit
b5826d226b
|
@ -63,9 +63,11 @@ public abstract class TileEntityIWBase extends TileEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void triggerRenderUpdate() {
|
public void triggerRenderUpdate() {
|
||||||
IBlockState state = world.getBlockState(pos);
|
if (world!=null) {
|
||||||
world.notifyBlockUpdate(pos, state, state, 3);
|
IBlockState state = world.getBlockState(pos);
|
||||||
world.addBlockEvent(pos, state.getBlock(), 255, 0);
|
world.notifyBlockUpdate(pos, state, state, 3);
|
||||||
|
world.addBlockEvent(pos, state.getBlock(), 255, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,6 +21,8 @@ import malte0811.industrialWires.blocks.BlockIWBase;
|
||||||
import malte0811.industrialWires.blocks.IMetaEnum;
|
import malte0811.industrialWires.blocks.IMetaEnum;
|
||||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||||
import malte0811.industrialWires.controlpanel.PropertyComponents;
|
import malte0811.industrialWires.controlpanel.PropertyComponents;
|
||||||
|
import malte0811.industrialWires.util.MiscUtils;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.properties.IProperty;
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.properties.PropertyEnum;
|
import net.minecraft.block.properties.PropertyEnum;
|
||||||
|
@ -86,6 +88,8 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
||||||
return new TileEntityUnfinishedPanel();
|
return new TileEntityUnfinishedPanel();
|
||||||
case SINGLE_COMP:
|
case SINGLE_COMP:
|
||||||
return new TileEntityComponentPanel();
|
return new TileEntityComponentPanel();
|
||||||
|
case DUMMY:
|
||||||
|
return new TileEntityGeneralCP();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -235,7 +239,7 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
||||||
return state.getValue(type)==BlockTypes_Panel.SINGLE_COMP;
|
return state.getValue(type)==BlockTypes_Panel.SINGLE_COMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Override
|
@Override
|
||||||
public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
|
public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
|
||||||
if (blockState.getValue(type)==BlockTypes_Panel.SINGLE_COMP) {
|
if (blockState.getValue(type)==BlockTypes_Panel.SINGLE_COMP) {
|
||||||
TileEntity te = blockAccess.getTileEntity(pos);
|
TileEntity te = blockAccess.getTileEntity(pos);
|
||||||
|
@ -256,5 +260,16 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||||
|
super.neighborChanged(state, worldIn, pos, blockIn, fromPos);
|
||||||
|
if (!worldIn.isRemote) {
|
||||||
|
TileEntityComponentPanel panel = MiscUtils.getExistingTE(worldIn, pos, TileEntityComponentPanel.class);
|
||||||
|
if (panel != null) {
|
||||||
|
panel.updateRSInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,58 +15,57 @@
|
||||||
|
|
||||||
package malte0811.industrialWires.blocks.controlpanel;
|
package malte0811.industrialWires.blocks.controlpanel;
|
||||||
|
|
||||||
|
import malte0811.industrialWires.controlpanel.ControlPanelNetwork;
|
||||||
|
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||||
|
import malte0811.industrialWires.controlpanel.PropertyComponents;
|
||||||
|
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||||
|
import net.minecraft.block.BlockRedstoneWire;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import static malte0811.industrialWires.util.MiscUtils.apply;
|
||||||
|
|
||||||
public class TileEntityComponentPanel extends TileEntityPanel {
|
public class TileEntityComponentPanel extends TileEntityPanel {
|
||||||
/*private int rsOut = 0; todo
|
private byte rsOut = 0;
|
||||||
private Consumer<byte[]> rsIn;
|
|
||||||
public TileEntityComponentPanel() {
|
public TileEntityComponentPanel() {
|
||||||
components = new PropertyComponents.AABBPanelProperties();
|
components = new PropertyComponents.AABBPanelProperties();
|
||||||
|
panelNetwork = new SingleCompNetwork();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void onLoad() {
|
||||||
for (PanelComponent pc : components) {
|
super.onLoad();
|
||||||
pc.update();
|
|
||||||
}
|
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
if (firstTick&&components.size()>0) {
|
updateRSInput();
|
||||||
PanelComponent pc = components.get(0);
|
|
||||||
pc.registerRSOutput(-1, (channel, value, pcTmp)->{
|
|
||||||
rsOut = value;
|
|
||||||
if (!isInvalid()) {
|
|
||||||
markBlockForUpdate(pos);
|
|
||||||
markBlockForUpdate(pos.offset(components.getTop(), -1));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
rsIn = pc.getRSInputHandler(-1, this);
|
|
||||||
updateRS();
|
|
||||||
firstTick = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateRS() {
|
public void updateRSInput() {
|
||||||
if (rsIn != null) {
|
int value = world.isBlockIndirectlyGettingPowered(pos);
|
||||||
int value = world.isBlockIndirectlyGettingPowered(pos);
|
if (value == 0) {
|
||||||
if (value == 0) {
|
for (EnumFacing f : EnumFacing.HORIZONTALS) {
|
||||||
for (EnumFacing f : EnumFacing.HORIZONTALS) {
|
IBlockState state = world.getBlockState(pos.offset(f));
|
||||||
IBlockState state = world.getBlockState(pos.offset(f));
|
if (state.getBlock() == Blocks.REDSTONE_WIRE && state.getValue(BlockRedstoneWire.POWER) > value)
|
||||||
if (state.getBlock() == Blocks.REDSTONE_WIRE && state.getValue(BlockRedstoneWire.POWER) > value)
|
value = state.getValue(BlockRedstoneWire.POWER);
|
||||||
value = state.getValue(BlockRedstoneWire.POWER);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
byte[] tmp = new byte[16];
|
|
||||||
for (int i = 0; i < tmp.length; i++) {
|
|
||||||
tmp[i] = (byte) value;
|
|
||||||
}
|
|
||||||
rsIn.accept(tmp);
|
|
||||||
}
|
}
|
||||||
|
((SingleCompNetwork)panelNetwork).setGlobalInput((byte) value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markBlockForUpdate(BlockPos pos)
|
public void markBlockForUpdate(BlockPos pos)
|
||||||
{
|
{
|
||||||
IBlockState state = world.getBlockState(getBlockPos());
|
if (world!=null) {
|
||||||
world.notifyBlockUpdate(pos,state,state,3);
|
IBlockState state = world.getBlockState(getBlockPos());
|
||||||
world.notifyNeighborsOfStateChange(pos, state.getBlock(), true);
|
world.notifyBlockUpdate(pos, state, state, 3);
|
||||||
|
world.notifyNeighborsOfStateChange(pos, state.getBlock(), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,31 +77,52 @@ public class TileEntityComponentPanel extends TileEntityPanel {
|
||||||
return defAABB;
|
return defAABB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerRS(TileEntityRSPanelConn te) {
|
|
||||||
//NO-OP
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unregisterRS(TileEntityRSPanelConn te) {
|
|
||||||
//NO-OP
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean interactsWithRSWires() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRSOutput() {
|
public int getRSOutput() {
|
||||||
return rsOut;
|
return rsOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getTileDrop(@Nonnull EntityPlayer player, @Nonnull IBlockState state) {
|
public ItemStack getTileDrop(EntityPlayer player, @Nonnull IBlockState state) {
|
||||||
if (components.size()<1) {
|
if (components.size()<1) {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
return ItemPanelComponent.stackFromComponent(components.get(0));
|
return ItemPanelComponent.stackFromComponent(components.get(0));
|
||||||
}
|
}
|
||||||
*/}
|
|
||||||
|
@Override
|
||||||
|
public boolean canJoinNetwork() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComponent(PanelComponent comp) {
|
||||||
|
components.clear();
|
||||||
|
components.add(comp);
|
||||||
|
comp.setPanel(this);
|
||||||
|
comp.setNetwork(panelNetwork);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SingleCompNetwork extends ControlPanelNetwork {
|
||||||
|
@Override
|
||||||
|
public void setOutputs(IOwner owner, RSChannelState... out) {
|
||||||
|
super.setOutputs(owner, out);
|
||||||
|
byte oldOut = rsOut;
|
||||||
|
rsOut = 0;
|
||||||
|
for (OutputValue s:activeOutputs.values()) {
|
||||||
|
rsOut = (byte) Math.max(rsOut, s.getTargetState().getStrength());
|
||||||
|
}
|
||||||
|
if (oldOut!=rsOut) {
|
||||||
|
markBlockForUpdate(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGlobalInput(byte value) {
|
||||||
|
for (RSChannel channel: listeners.keySet()) {
|
||||||
|
RSChannelState state = new RSChannelState(channel, value);
|
||||||
|
for (ChangeListener l:listeners.get(channel)) {
|
||||||
|
l.onChange(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -19,12 +19,13 @@ import malte0811.industrialWires.blocks.TileEntityIWBase;
|
||||||
import malte0811.industrialWires.controlpanel.ControlPanelNetwork;
|
import malte0811.industrialWires.controlpanel.ControlPanelNetwork;
|
||||||
import malte0811.industrialWires.controlpanel.ControlPanelNetwork.IOwner;
|
import malte0811.industrialWires.controlpanel.ControlPanelNetwork.IOwner;
|
||||||
import malte0811.industrialWires.util.MiscUtils;
|
import malte0811.industrialWires.util.MiscUtils;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public abstract class TileEntityGeneralCP extends TileEntityIWBase implements IOwner {
|
public class TileEntityGeneralCP extends TileEntityIWBase implements IOwner {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
protected ControlPanelNetwork panelNetwork = new ControlPanelNetwork();
|
protected ControlPanelNetwork panelNetwork = new ControlPanelNetwork();
|
||||||
|
|
||||||
|
@ -37,16 +38,18 @@ public abstract class TileEntityGeneralCP extends TileEntityIWBase implements IO
|
||||||
super.onLoad();
|
super.onLoad();
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
boolean isFinalNet = false;
|
boolean isFinalNet = false;
|
||||||
for (EnumFacing side : EnumFacing.VALUES) {
|
if (canJoinNetwork()) {
|
||||||
BlockPos posSide = pos.offset(side);
|
for (EnumFacing side : EnumFacing.VALUES) {
|
||||||
TileEntityGeneralCP neighbour = MiscUtils.getExistingTE(world, posSide, TileEntityGeneralCP.class);
|
BlockPos posSide = pos.offset(side);
|
||||||
if (neighbour != null) {
|
TileEntityGeneralCP neighbour = MiscUtils.getExistingTE(world, posSide, TileEntityGeneralCP.class);
|
||||||
if (!isFinalNet) {
|
if (neighbour != null && neighbour.canJoinNetwork()) {
|
||||||
panelNetwork = neighbour.panelNetwork;
|
if (!isFinalNet) {
|
||||||
panelNetwork.addMember(this);
|
panelNetwork = neighbour.panelNetwork;
|
||||||
isFinalNet = true;
|
panelNetwork.addMember(this);
|
||||||
} else {
|
isFinalNet = true;
|
||||||
neighbour.panelNetwork.replaceWith(panelNetwork, world);
|
} else {
|
||||||
|
neighbour.panelNetwork.replaceWith(panelNetwork, world);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +65,12 @@ public abstract class TileEntityGeneralCP extends TileEntityIWBase implements IO
|
||||||
panelNetwork.removeMember(pos, world);
|
panelNetwork.removeMember(pos, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeNBT(NBTTagCompound out, boolean updatePacket) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readNBT(NBTTagCompound in, boolean updatePacket) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
super.invalidate();
|
super.invalidate();
|
||||||
|
@ -72,4 +81,8 @@ public abstract class TileEntityGeneralCP extends TileEntityIWBase implements IO
|
||||||
public BlockPos getBlockPos() {
|
public BlockPos getBlockPos() {
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canJoinNetwork() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,9 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static malte0811.industrialWires.util.MiscUtils.apply;
|
import static malte0811.industrialWires.util.MiscUtils.apply;
|
||||||
|
|
||||||
public class TileEntityPanel extends TileEntityGeneralCP implements IDirectionalTile, IBlockBoundsIW, IPlayerInteraction, ITickable, IEBlockInterfaces.ITileDrop {
|
public class TileEntityPanel extends TileEntityGeneralCP implements IDirectionalTile, IBlockBoundsIW, IPlayerInteraction,
|
||||||
|
ITickable, IEBlockInterfaces.ITileDrop {
|
||||||
protected PropertyComponents.PanelRenderProperties components = new PropertyComponents.PanelRenderProperties();
|
protected PropertyComponents.PanelRenderProperties components = new PropertyComponents.PanelRenderProperties();
|
||||||
public boolean firstTick = true;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
int[] colors = {
|
int[] colors = {
|
||||||
|
@ -132,9 +132,11 @@ public class TileEntityPanel extends TileEntityGeneralCP implements IDirectional
|
||||||
NBTTagList l = nbt.getTagList("components", 10);
|
NBTTagList l = nbt.getTagList("components", 10);
|
||||||
PanelUtils.readListFromNBT(l, components);
|
PanelUtils.readListFromNBT(l, components);
|
||||||
panelNetwork.removeIOFor(this);
|
panelNetwork.removeIOFor(this);
|
||||||
for (PanelComponent pc:components) {
|
for (PanelComponent pc : components) {
|
||||||
pc.setPanel(this);
|
pc.setPanel(this);
|
||||||
pc.setNetwork(panelNetwork);
|
if (world == null || !world.isRemote) {
|
||||||
|
pc.setNetwork(panelNetwork);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
components.setHeight(nbt.getFloat("height"));
|
components.setHeight(nbt.getFloat("height"));
|
||||||
components.setAngle(nbt.getFloat("angle"));
|
components.setAngle(nbt.getFloat("angle"));
|
||||||
|
|
|
@ -32,11 +32,11 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||||
public class ControlPanelNetwork {
|
public class ControlPanelNetwork {
|
||||||
private Map<RSChannel, List<ChangeListener>> listeners = new HashMap<>();
|
protected Map<RSChannel, List<ChangeListener>> listeners = new HashMap<>();
|
||||||
private Map<RSChannel, List<OutputValue>> allOutputs = new HashMap<>();
|
protected Map<RSChannel, List<OutputValue>> allOutputs = new HashMap<>();
|
||||||
private Map<RSChannel, OutputValue> activeOutputs = new HashMap<>();
|
protected Map<RSChannel, OutputValue> activeOutputs = new HashMap<>();
|
||||||
private Map<RSChannel, OutputValue> secondActiveOutputs = new HashMap<>();
|
protected Map<RSChannel, OutputValue> secondActiveOutputs = new HashMap<>();
|
||||||
private Set<BlockPos> members = new HashSet<>();
|
protected Set<BlockPos> members = new HashSet<>();
|
||||||
|
|
||||||
public void addListener(IOwner owner, Consumer<RSChannelState> listener, RSChannel... channels) {
|
public void addListener(IOwner owner, Consumer<RSChannelState> listener, RSChannel... channels) {
|
||||||
ChangeListener l = new ChangeListener(owner, listener);
|
ChangeListener l = new ChangeListener(owner, listener);
|
||||||
|
@ -232,7 +232,7 @@ public class ControlPanelNetwork {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ChangeListener extends Owned {
|
protected static class ChangeListener extends Owned {
|
||||||
private final Consumer<RSChannelState> listener;
|
private final Consumer<RSChannelState> listener;
|
||||||
|
|
||||||
private ChangeListener(IOwner owner, Consumer<RSChannelState> listener) {
|
private ChangeListener(IOwner owner, Consumer<RSChannelState> listener) {
|
||||||
|
@ -245,7 +245,7 @@ public class ControlPanelNetwork {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class OutputValue extends Owned {
|
protected static class OutputValue extends Owned {
|
||||||
private final RSChannelState targetState;
|
private final RSChannelState targetState;
|
||||||
|
|
||||||
private OutputValue(@Nullable IOwner owner, RSChannelState targetState) {
|
private OutputValue(@Nullable IOwner owner, RSChannelState targetState) {
|
||||||
|
|
|
@ -136,7 +136,7 @@ public abstract class PanelComponent implements IOwner {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockPos getBlockPos() {
|
public BlockPos getBlockPos() {
|
||||||
return panel.getBlockPos();
|
return panel.getPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound nbt, boolean toItem) {
|
public void writeToNBT(NBTTagCompound nbt, boolean toItem) {
|
||||||
|
|
|
@ -17,14 +17,14 @@ package malte0811.industrialWires.items;
|
||||||
|
|
||||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||||
import blusunrize.immersiveengineering.client.ClientProxy;
|
import blusunrize.immersiveengineering.client.ClientProxy;
|
||||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
|
|
||||||
import malte0811.industrialWires.IndustrialWires;
|
import malte0811.industrialWires.IndustrialWires;
|
||||||
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
|
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
|
||||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
|
import malte0811.industrialWires.blocks.controlpanel.TileEntityComponentPanel;
|
||||||
import malte0811.industrialWires.controlpanel.IConfigurableComponent;
|
import malte0811.industrialWires.controlpanel.IConfigurableComponent;
|
||||||
import malte0811.industrialWires.controlpanel.PanelComponent;
|
import malte0811.industrialWires.controlpanel.PanelComponent;
|
||||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||||
import malte0811.industrialWires.controlpanel.SevenSegDisplay;
|
import malte0811.industrialWires.controlpanel.SevenSegDisplay;
|
||||||
|
import malte0811.industrialWires.util.MiscUtils;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -33,13 +33,11 @@ import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -187,7 +185,7 @@ public class ItemPanelComponent extends Item implements INetGUIItem {
|
||||||
|
|
||||||
ItemStack itemstack = player.getHeldItem(hand);
|
ItemStack itemstack = player.getHeldItem(hand);
|
||||||
|
|
||||||
if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack) && worldIn.mayPlace(IndustrialWires.panel, pos, false, facing, (Entity) null)) {
|
if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack) && worldIn.mayPlace(IndustrialWires.panel, pos, false, facing, null)) {
|
||||||
placeBlockAt(itemstack, player, worldIn, pos, facing, hitX, hitY, hitZ);
|
placeBlockAt(itemstack, player, worldIn, pos, facing, hitX, hitY, hitZ);
|
||||||
SoundType soundtype = worldIn.getBlockState(pos).getBlock().getSoundType(worldIn.getBlockState(pos), worldIn, pos, player);
|
SoundType soundtype = worldIn.getBlockState(pos).getBlock().getSoundType(worldIn.getBlockState(pos), worldIn, pos, player);
|
||||||
worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
||||||
|
@ -202,17 +200,11 @@ public class ItemPanelComponent extends Item implements INetGUIItem {
|
||||||
private void placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
private void placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
IBlockState state = IndustrialWires.panel.getStateFromMeta(BlockTypes_Panel.SINGLE_COMP.ordinal());
|
IBlockState state = IndustrialWires.panel.getStateFromMeta(BlockTypes_Panel.SINGLE_COMP.ordinal());
|
||||||
world.setBlockState(pos, state);
|
world.setBlockState(pos, state);
|
||||||
TileEntity te = world.getTileEntity(pos);
|
TileEntityComponentPanel te = MiscUtils.getExistingTE(world, pos, TileEntityComponentPanel.class);
|
||||||
if (te instanceof IEBlockInterfaces.IDirectionalTile) {
|
if (te!=null) {
|
||||||
EnumFacing dir = ((IEBlockInterfaces.IDirectionalTile) te).getFacingForPlacement(player, pos, side, hitX, hitY, hitZ);
|
EnumFacing dir = te.getFacingForPlacement(player, pos, side, hitX, hitY, hitZ);
|
||||||
((IEBlockInterfaces.IDirectionalTile) te).setFacing(dir);
|
te.setFacing(dir);
|
||||||
}
|
te.setComponent(componentFromStack(stack));
|
||||||
if (te instanceof IEBlockInterfaces.ITileDrop) {
|
|
||||||
((IEBlockInterfaces.ITileDrop) te).readOnPlacement(player, stack);
|
|
||||||
}
|
|
||||||
if (te instanceof TileEntityPanel) {
|
|
||||||
((TileEntityPanel) te).getComponents().clear();
|
|
||||||
((TileEntityPanel) te).getComponents().add(componentFromStack(stack));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue