Added sliders to control panels, they can be used to set an RS signal between 0 and 15

Commented out the IE gradle dependency since no maven build of IE works with control panels yet (latest master does though)
This commit is contained in:
malte0811 2017-04-04 17:07:45 +02:00
parent 3641775ff5
commit 3d4c2ef1f4
16 changed files with 345 additions and 65 deletions

View file

@ -70,7 +70,7 @@ repositories {
dependencies {
deobfCompile "net.industrial-craft:industrialcraft-2:2.6.+"
deobfCompile "blusunrize:ImmersiveEngineering:0.10-+:deobf"
//deobfCompile "blusunrize:ImmersiveEngineering:0.10-+:deobf"
}
jar {

View file

@ -17,9 +17,6 @@
*/
package malte0811.industrialWires;
import java.util.ArrayList;
import java.util.List;
import blusunrize.immersiveengineering.api.tool.AssemblerHandler;
import blusunrize.immersiveengineering.api.tool.AssemblerHandler.IRecipeAdapter;
import blusunrize.immersiveengineering.api.tool.AssemblerHandler.RecipeQuery;
@ -37,14 +34,10 @@ import malte0811.industrialWires.blocks.converter.BlockMechanicalConverter;
import malte0811.industrialWires.blocks.converter.TileEntityIEMotor;
import malte0811.industrialWires.blocks.converter.TileEntityMechICtoIE;
import malte0811.industrialWires.blocks.converter.TileEntityMechIEtoIC;
import malte0811.industrialWires.blocks.wire.BlockIC2Connector;
import malte0811.industrialWires.blocks.wire.TileEntityIC2ConnectorCopper;
import malte0811.industrialWires.blocks.wire.TileEntityIC2ConnectorGlass;
import malte0811.industrialWires.blocks.wire.TileEntityIC2ConnectorGold;
import malte0811.industrialWires.blocks.wire.TileEntityIC2ConnectorHV;
import malte0811.industrialWires.blocks.wire.TileEntityIC2ConnectorTin;
import malte0811.industrialWires.blocks.wire.*;
import malte0811.industrialWires.crafting.RecipeCoilLength;
import malte0811.industrialWires.items.ItemIC2Coil;
import malte0811.industrialWires.network.MessagePanelInteract;
import malte0811.industrialWires.network.MessageTileSyncIW;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.creativetab.CreativeTabs;
@ -65,6 +58,9 @@ import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.RecipeSorter.Category;
import net.minecraftforge.oredict.ShapedOreRecipe;
import java.util.ArrayList;
import java.util.List;
@Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies="required-after:immersiveengineering@[0.10-53,);required-after:IC2")
public class IndustrialWires {
public static final String MODID = "industrialwires";
@ -167,6 +163,7 @@ public class IndustrialWires {
's', "ingotSteel", 't', new ItemStack(IEContent.blockConnectors, 1, BlockTypes_Connector.TRANSFORMER_HV.ordinal())));
packetHandler.registerMessage(MessageTileSyncIW.HandlerClient.class, MessageTileSyncIW.class, 0, Side.CLIENT);
packetHandler.registerMessage(MessagePanelInteract.HandlerServer.class, MessagePanelInteract.class, 1, Side.SERVER);
}
@EventHandler
public void postInit(FMLPostInitializationEvent e) {

View file

@ -18,10 +18,8 @@
package malte0811.industrialWires.blocks;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
import blusunrize.immersiveengineering.common.util.IELogger;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;

View file

@ -102,6 +102,11 @@ public class IndicatorLight extends PanelComponent {
return null;
}
@Override
public float getHeight() {
return 0;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;

View file

@ -3,7 +3,6 @@ package malte0811.industrialWires.blocks.controlpanel;
import malte0811.industrialWires.client.RawQuad;
import malte0811.industrialWires.client.panelmodel.RawModelFontRenderer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
@ -71,6 +70,11 @@ public class Label extends PanelComponent {
}
@Override
public float getHeight() {
return 0;
}
private RawModelFontRenderer fontRenderer() {
if (renderer==null) {
renderer = new RawModelFontRenderer(Minecraft.getMinecraft().gameSettings, font, Minecraft.getMinecraft().getTextureManager(),

View file

@ -72,7 +72,6 @@ public class LightedButton extends PanelComponent {
rsOutputChannel = nbt.getInteger("rsChannel");
rsOutputId = nbt.getInteger("rsId");
}
private final static float[] sideColor = {.8F, .8F, .8F};
private final static float size = .0625F;
@Override
public List<RawQuad> getQuads() {
@ -82,7 +81,7 @@ public class LightedButton extends PanelComponent {
color[i] = ((this.color>>(8*(2-i)))&255)/255F*(active?1:.5F);
}
List<RawQuad> ret = new ArrayList<>(5);
PanelUtils.addColoredBox(color, sideColor, null, new Vector3f(0, 0, 0), new Vector3f(size, size/2, size), ret, false);
PanelUtils.addColoredBox(color, gray, null, new Vector3f(0, 0, 0), new Vector3f(size, size/2, size), ret, false);
return ret;
}
@ -99,7 +98,7 @@ public class LightedButton extends PanelComponent {
@Override
public AxisAlignedBB getBlockRelativeAABB() {
if (aabb==null) {
aabb = new AxisAlignedBB(x, 0, y, x+size, size/2, y+size);
aabb = new AxisAlignedBB(x, 0, y, x+size, getHeight(), y+size);
}
return aabb;
}
@ -144,6 +143,11 @@ public class LightedButton extends PanelComponent {
}
}
@Override
public float getHeight() {
return size/2;
}
private void setOut(boolean on, TileEntityPanel tile) {
active = on;
tile.markDirty();

View file

@ -22,7 +22,6 @@ import blusunrize.immersiveengineering.common.util.IELogger;
import malte0811.industrialWires.client.RawQuad;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.AxisAlignedBB;
@ -41,6 +40,7 @@ public abstract class PanelComponent {
protected float panelHeight;
protected float x, y;
private final String type;
protected final static float[] gray = {.8F, .8F, .8F};
protected PanelComponent(String type) {
this.type = type;
}
@ -49,6 +49,7 @@ public abstract class PanelComponent {
baseCreaters.put("lightedButton", LightedButton::new);
baseCreaters.put("label", Label::new);
baseCreaters.put("indicator_light", IndicatorLight::new);
baseCreaters.put("slider", Slider::new);
}
protected abstract void writeCustomNBT(NBTTagCompound nbt);
protected abstract void readCustomNBT(NBTTagCompound nbt);
@ -81,6 +82,8 @@ public abstract class PanelComponent {
return y;
}
public abstract float getHeight();
public void setX(float x) {
this.x = x;
}
@ -110,7 +113,7 @@ public abstract class PanelComponent {
ret.setPanelHeight(nbt.getFloat("panelHeight"));
return ret;
} else {
IELogger.info("(IndustrialWires) Unknown panel component: "+type);
IELogger.info("(IndustrialWires) Unknown panel component: "+type);//TODO own logger?
return null;
}
}

View file

@ -50,7 +50,6 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
public EnumFacing facing = EnumFacing.NORTH;
public float height = .5F;
public EnumFacing top = EnumFacing.UP;
public TileEntityPanel panel;//Don't compare this+erase it on copying
public PanelRenderProperties() {
super();
}
@ -92,6 +91,17 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
return ret;
}
public float getMaxHeight() {
float ret = 0;
for (PanelComponent pc:this) {
float hHere = pc.getHeight();
if (hHere>ret) {
ret = hHere;
}
}
return ret+height;
}
public PanelRenderProperties copyOf() {
PanelRenderProperties ret = new PanelRenderProperties(size());
for (PanelComponent pc:this) {

View file

@ -0,0 +1,170 @@
package malte0811.industrialWires.blocks.controlpanel;
import malte0811.industrialWires.client.RawQuad;
import malte0811.industrialWires.client.panelmodel.PanelUtils;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.Vec3d;
import org.lwjgl.util.vector.Vector3f;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.BiConsumer;
public class Slider extends PanelComponent {
private static final float WIDTH = .0625F;
private float length;
private int color;
private boolean horizontal;
private byte out;
private byte rsChannel;
private int rsId;
private Set<BiConsumer<Integer, Byte>> outputs = new HashSet<>();
public Slider(float length, int color, boolean horizontal, int rsId, byte rsChannel) {
this();
this.color = color;
this.length = length;
this.horizontal = horizontal;
this.rsChannel = rsChannel;
this.rsId = rsId;
}
public Slider() {
super("slider");
}
@Override
protected void writeCustomNBT(NBTTagCompound nbt) {
nbt.setInteger("color", color);
nbt.setFloat("length", length);
nbt.setByte("output", out);
nbt.setByte("rsChannel", rsChannel);
nbt.setInteger("rsId", rsId);
nbt.setBoolean("horizontal", horizontal);
}
@Override
protected void readCustomNBT(NBTTagCompound nbt) {
color = nbt.getInteger("color");
length = nbt.getFloat("length");
out = nbt.getByte("output");
rsChannel = nbt.getByte("rsChannel");
rsId = nbt.getInteger("rsId");
horizontal = nbt.getBoolean("horizontal");
}
@Override
public List<RawQuad> getQuads() {
List<RawQuad> ret = new ArrayList<>();
final float yOff = .001F;
float xSize = horizontal?length:WIDTH;
float ySize = horizontal?WIDTH:length;
PanelUtils.addColoredQuad(ret, new Vector3f(0, yOff, 0), new Vector3f(0, yOff, ySize), new Vector3f(xSize, yOff, ySize), new Vector3f(xSize, yOff, 0),
EnumFacing.UP, gray);
float[] color = new float[4];
color[3] = 1;
for (int i = 0;i<3;i++) {
color[i] = ((this.color>>(8*(2-i)))&255)/255F*(.5F+out/30F);
}
float val;
if (horizontal) {
val = (out/15F)*(length-.0625F);
} else {
val = (1-out/15F)*(length-.0625F);
}
PanelUtils.addColoredBox(color, gray, null, new Vector3f(horizontal?val:0, 0, horizontal?0:val),
new Vector3f(.0625F, getHeight(), .0625F), ret, false);
return ret;
}
@Nonnull
@Override
public PanelComponent copyOf() {
Slider ret = new Slider(length, color, horizontal, rsId, rsChannel);
ret.out = out;
ret.setX(x);
ret.setY(y);
ret.panelHeight = panelHeight;
return ret;
}
private AxisAlignedBB aabb;
@Override
public AxisAlignedBB getBlockRelativeAABB() {
if (aabb==null) {
aabb = new AxisAlignedBB(x, 0, y, x+(horizontal?length:WIDTH), getHeight(), y+(horizontal?WIDTH:length));
}
return aabb;
}
@Override
public boolean interactWith(Vec3d hitRelative, TileEntityPanel tile) {
double pos = horizontal?hitRelative.xCoord:(length-hitRelative.zCoord);
byte newLevel = (byte)(Math.min(pos*16/length, 15));
if (newLevel!=out) {
for (BiConsumer<Integer, Byte> output:outputs) {
output.accept((int)rsChannel, newLevel);
}
out = newLevel;
tile.markDirty();
tile.triggerRenderUpdate();
return true;
}
return false;
}
@Override
public void registerRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {
if (id==rsId) {
outputs.add(out);
out.accept((int)rsChannel, this.out);
}
}
@Override
public void unregisterRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {
if (id==rsId) {
outputs.remove(out);
}
}
@Override
public void update(TileEntityPanel tile) {
}
@Override
public float getHeight() {
return .0625F/2;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
Slider slider = (Slider) o;
if (Float.compare(slider.length, length) != 0) return false;
if (color != slider.color) return false;
if (horizontal != slider.horizontal) return false;
if (out != slider.out) return false;
if (rsChannel != slider.rsChannel) return false;
return rsId == slider.rsId;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (length != +0.0f ? Float.floatToIntBits(length) : 0);
result = 31 * result + color;
result = 31 * result + (horizontal ? 1 : 0);
result = 31 * result + (int) out;
result = 31 * result + (int) rsChannel;
result = 31 * result + rsId;
return result;
}
}

View file

@ -21,8 +21,10 @@ package malte0811.industrialWires.blocks.controlpanel;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IPlayerInteraction;
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.IBlockBoundsIW;
import malte0811.industrialWires.blocks.TileEntityIWBase;
import malte0811.industrialWires.network.MessagePanelInteract;
import malte0811.industrialWires.util.MiscUtils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
@ -52,26 +54,31 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
private PropertyComponents.PanelRenderProperties components = new PropertyComponents.PanelRenderProperties();
private boolean firstTick = true;
// non-rendered properties
Set<TileEntityRSPanelConn> rsPorts = new HashSet<>();
private Set<TileEntityRSPanelConn> rsPorts = new HashSet<>();
{
for (int i = 0;i<16;i++) {
int color = EnumDyeColor.byMetadata(i).getMapColor().colorValue;
IndicatorLight ind = new IndicatorLight(0, i, color);
LightedButton btn = new LightedButton(color, false, true, 1, i);
for (int i = 2;i<14;i++) {
int color = EnumDyeColor.byMetadata(i-2).getMapColor().colorValue;
IndicatorLight ind = new IndicatorLight(0, i-2, color);
LightedButton btn = new LightedButton(color, false, true, 1, i-2);
Label lbl = new Label("->", color);
ind.setX(0);
ind.setY(i/16F);
ind.setPanelHeight(.5F);
ind.setPanelHeight(components.height);
lbl.setX(2/16F);
lbl.setY(i/16F);
lbl.setPanelHeight(.5F);
lbl.setPanelHeight(components.height);
btn.setX(5/16F);
btn.setY(i/16F);
btn.setPanelHeight(.5F);
btn.setPanelHeight(components.height);
components.add(ind);
components.add(lbl);
components.add(btn);
}
Slider slid = new Slider(.5F, 0x00ff00, true, 1, (byte)1);
slid.setX(.4F);
slid.setY(.25F);
slid.setPanelHeight(components.height);
components.add(slid);
}
@Override
@ -176,7 +183,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
@Override
public AxisAlignedBB getBoundingBox() {
if (defAABB==null) {
defAABB = apply(components.getPanelBaseTransform(), new AxisAlignedBB(0, 0, 0, 1, components.height, 1));
defAABB = apply(components.getPanelBaseTransform(), new AxisAlignedBB(0, 0, 0, 1, components.getMaxHeight(), 1));
}
return defAABB;
}
@ -195,25 +202,54 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
@Nullable
public Pair<PanelComponent, RayTraceResult> getSelectedComponent(EntityPlayer player, Vec3d hit, boolean hitAbs) {
Matrix4 mat = components.getPanelTopTransform();
PanelComponent retPc = null;
RayTraceResult retRay = null;
Vec3d playerPos = Minecraft.getMinecraft().thePlayer.getPositionVector().addVector(-pos.getX(), player.getEyeHeight() - pos.getY(), -pos.getZ());
for (PanelComponent pc : components) {
AxisAlignedBB box = pc.getBlockRelativeAABB();
if (box!=null) {
box = apply(mat, box.expandXyz(.002));
Vec3d hitVec = hitAbs ? hit.addVector(-pos.getX(), -pos.getY(), -pos.getZ()) : hit;
Vec3d playerPos = Minecraft.getMinecraft().thePlayer.getPositionVector().addVector(-pos.getX(), player.getEyeHeight() - pos.getY(), -pos.getZ());
hitVec = hitVec.scale(2).subtract(playerPos);
RayTraceResult ray = box.calculateIntercept(playerPos, hitVec);
if (ray != null) {
return new ImmutablePair<>(pc, ray);
if (retPc==null) {
retPc = pc;
retRay = ray;
} else {
double oldDist = retRay.hitVec.subtract(playerPos).lengthSquared();
double newDist = ray.hitVec.subtract(playerPos).lengthSquared();
if (newDist<oldDist) {
retPc = pc;
retRay = ray;
}
}
}
}
}
return null;
return retPc!=null?new ImmutablePair<>(retPc, retRay):null;
}
@Override
public boolean interact(EnumFacing side, EntityPlayer player, EnumHand hand, ItemStack heldItem, float hitX, float hitY, float hitZ) {
Pair<PanelComponent, RayTraceResult> pc = getSelectedComponent(player, new Vec3d(hitX, hitY, hitZ), false);
return pc != null && pc.getLeft().interactWith(pc.getRight().hitVec, this);
if (worldObj.isRemote) {
Pair<PanelComponent, RayTraceResult> pc = getSelectedComponent(player, new Vec3d(hitX, hitY, hitZ), false);
if (pc != null) {
Matrix4 inv = components.getPanelTopTransform();
inv.translate(pc.getLeft().getX(), 0, pc.getLeft().getY());
inv.invert();
Vec3d hitVec = inv.apply(pc.getRight().hitVec);
hitVec.subtract(pc.getLeft().getX(), 0, -pc.getLeft().getY());
IndustrialWires.packetHandler.sendToServer(new MessagePanelInteract(this, components.indexOf(pc.getKey()), hitVec));
}
}
return true;
}
public void interactServer(Vec3d hitRelative, int pcId) {
if (pcId>=0&&pcId<components.size()) {
components.get(pcId).interactWith(hitRelative, this);
}
}
public void triggerRenderUpdate() {

View file

@ -18,19 +18,11 @@
package malte0811.industrialWires.blocks.converter;
import blusunrize.immersiveengineering.api.IEProperties;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
import blusunrize.immersiveengineering.common.util.IELogger;
import blusunrize.immersiveengineering.common.util.Utils;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.BlockIWBase;
import malte0811.industrialWires.blocks.IMetaEnum;
import malte0811.industrialWires.blocks.ItemBlockIW;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
@ -39,13 +31,9 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import java.util.List;

View file

@ -17,14 +17,7 @@
*/
package malte0811.industrialWires.blocks.wire;
import java.util.Arrays;
import java.util.List;
import blusunrize.immersiveengineering.api.IEProperties;
import blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable;
import blusunrize.immersiveengineering.common.blocks.BlockIETileProvider;
import blusunrize.immersiveengineering.common.blocks.ItemBlockIEBase;
import blusunrize.immersiveengineering.common.util.IELogger;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.BlockIWBase;
import malte0811.industrialWires.blocks.IMetaEnum;
@ -44,9 +37,11 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import java.util.Arrays;
import java.util.List;
public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
private static PropertyEnum<BlockTypes_IC2_Connector> type = PropertyEnum.create("type", BlockTypes_IC2_Connector.class);
public BlockIC2Connector() {

View file

@ -18,21 +18,18 @@
package malte0811.industrialWires.client.panelmodel;
import blusunrize.immersiveengineering.common.util.IELogger;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableList;
import malte0811.industrialWires.blocks.controlpanel.PropertyComponents;
import malte0811.industrialWires.blocks.controlpanel.PropertyComponents.PanelRenderProperties;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.property.IExtendedBlockState;
import javax.annotation.Nullable;
@ -53,11 +50,9 @@ public class PanelModel implements IBakedModel {
}
if (state instanceof IExtendedBlockState) {
PanelRenderProperties cl = ((IExtendedBlockState) state).getValue(PropertyComponents.INSTANCE);
if (cl == null) {
return ImmutableList.of();
}
IELogger.info(modelCache.size());
AssembledBakedModel m = modelCache.getIfPresent(cl);
if (m == null) {
m = new AssembledBakedModel(cl);

View file

@ -18,12 +18,8 @@
package malte0811.industrialWires.client.panelmodel;
import blusunrize.immersiveengineering.common.util.IELogger;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import malte0811.industrialWires.IndustrialWires;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
@ -32,11 +28,12 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ICustomModelLoader;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.model.obj.OBJModel;
import net.minecraftforge.common.model.IModelState;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class PanelModelLoader implements ICustomModelLoader {
public static final String RESOURCE_BASE = "models/block/";

View file

@ -1,6 +1,5 @@
package malte0811.industrialWires.client.panelmodel;
import blusunrize.immersiveengineering.common.util.IELogger;
import com.google.common.collect.ImmutableList;
import malte0811.industrialWires.client.RawQuad;
import net.minecraft.client.Minecraft;

View file

@ -0,0 +1,79 @@
/*
* This file is part of Industrial Wires.
* Copyright (C) 2016-2017 malte0811
*
* Industrial Wires is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Industrial Wires is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*/
package malte0811.industrialWires.network;
import io.netty.buffer.ByteBuf;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
public class MessagePanelInteract implements IMessage {
private BlockPos pos;
//private int dimension;
private int pcId;
private Vec3d hitRelative;
public MessagePanelInteract(TileEntityPanel tile, int id, Vec3d hit) {
pos = tile.getPos();
//dimension = tile.getWorld().provider.getDimension();
pcId = id;
hitRelative = hit;
}
public MessagePanelInteract() {}
@Override
public void fromBytes(ByteBuf buf) {
this.pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
//dimension = buf.readInt();
pcId = buf.readInt();
hitRelative = new Vec3d(buf.readDouble(), buf.readDouble(), buf.readDouble());
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(this.pos.getX());
buf.writeInt(this.pos.getY());
buf.writeInt(this.pos.getZ());
//buf.writeInt(dimension);
buf.writeInt(pcId);
buf.writeDouble(hitRelative.xCoord).writeDouble(hitRelative.yCoord).writeDouble(hitRelative.zCoord);
}
public static class HandlerServer implements IMessageHandler<MessagePanelInteract, IMessage> {
@Override
public IMessage onMessage(MessagePanelInteract message, MessageContext ctx) {
ctx.getServerHandler().playerEntity.getServerWorld().addScheduledTask(()->handle(message, ctx.getServerHandler().playerEntity));
return null;
}
private void handle(MessagePanelInteract msg, EntityPlayerMP player) {
if (player.getDistanceSqToCenter(msg.pos)<100) {//closer than 10 blocks TODO use player reach distance?
TileEntity te = player.worldObj.getTileEntity(msg.pos);
if (te instanceof TileEntityPanel) {
((TileEntityPanel) te).interactServer(msg.hitRelative, msg.pcId);
}
}
}
}
}