mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
~80 errors remaining. Need to properly add offhand support for most items
This commit is contained in:
1 parent
a89b8f666c
commit
79af86daae
40 files changed
+586
-436
No files matched your search
@@ -1,6 +1,8 @@
|
||||
package mekanism.api;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
/**
|
||||
* Implement this class in your TileEntity if it can interact with Mekanism alloys.
|
||||
@@ -12,7 +14,9 @@ public interface IAlloyInteraction
|
||||
/**
|
||||
* Called when a player right-clicks this block with an alloy.
|
||||
* @param player - the player right-clicking the block
|
||||
* @param hand - the hand this alloy was right-clicked with
|
||||
* @param stack - the stack of alloy being right-clicked
|
||||
* @param tierOrdinal - the ordinal tier of the alloy (1 = advanced, 2 = elite, 3 = ultimate)
|
||||
*/
|
||||
public void onAlloyInteraction(EntityPlayer player, int tierOrdinal);
|
||||
public void onAlloyInteraction(EntityPlayer player, EnumHand hand, ItemStack stack, int tierOrdinal);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package mekanism.client;
|
||||
|
||||
import static mekanism.common.block.states.BlockStatePlastic.colorProperty;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -112,7 +114,9 @@ import mekanism.common.Tier.GasTankTier;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.BlockMachine;
|
||||
import mekanism.common.block.states.BlockStateBasic.BasicBlockType;
|
||||
import mekanism.common.block.states.BlockStateMachine;
|
||||
import mekanism.common.block.states.BlockStateMachine.MachineType;
|
||||
import mekanism.common.block.states.BlockStateOre.EnumOreType;
|
||||
import mekanism.common.entity.EntityBabySkeleton;
|
||||
@@ -124,6 +128,7 @@ import mekanism.common.inventory.InventoryPersonalChest;
|
||||
import mekanism.common.item.ItemBlockBasic;
|
||||
import mekanism.common.item.ItemBlockGasTank;
|
||||
import mekanism.common.item.ItemBlockMachine;
|
||||
import mekanism.common.item.ItemBlockPlastic;
|
||||
import mekanism.common.item.ItemCraftingFormula;
|
||||
import mekanism.common.item.ItemPortableTeleporter;
|
||||
import mekanism.common.item.ItemSeismicReader;
|
||||
@@ -188,6 +193,7 @@ import mekanism.common.tile.TileEntitySeismicVibrator;
|
||||
import mekanism.common.tile.TileEntitySolarNeutronActivator;
|
||||
import mekanism.common.tile.TileEntityTeleporter;
|
||||
import mekanism.common.tile.TileEntityThermalEvaporationController;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -195,11 +201,14 @@ import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderSkeleton;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -207,6 +216,7 @@ import net.minecraft.util.EnumFacing;
|
||||
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.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
@@ -408,6 +418,64 @@ public class ClientProxy extends CommonProxy
|
||||
@Override
|
||||
public void registerBlockRenders()
|
||||
{
|
||||
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(new IBlockColor() {
|
||||
@Override
|
||||
public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex)
|
||||
{
|
||||
BlockMachine machine = (BlockMachine)state.getBlock();
|
||||
|
||||
if(state.getValue(machine.getMachineBlock().getProperty()) == MachineType.FLUID_TANK)
|
||||
{
|
||||
EnumColor color = state.getValue(BlockStateMachine.tierProperty).getColor();
|
||||
|
||||
return (int)(color.getColor(0)*255) << 16 | (int)(color.getColor(1)*255) << 8 | (int)(color.getColor(2)*255);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}, MekanismBlocks.MachineBlock, MekanismBlocks.MachineBlock2, MekanismBlocks.MachineBlock3);
|
||||
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(new IBlockColor() {
|
||||
@Override
|
||||
public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex)
|
||||
{
|
||||
EnumDyeColor color = state.getValue(colorProperty);
|
||||
EnumColor dye = EnumColor.DYES[color.getDyeDamage()];
|
||||
|
||||
return (int)(dye.getColor(0)*255) << 16 | (int)(dye.getColor(1)*255) << 8 | (int)(dye.getColor(2)*255);
|
||||
}
|
||||
}, MekanismBlocks.PlasticBlock, MekanismBlocks.GlowPlasticBlock, MekanismBlocks.RoadPlasticBlock, MekanismBlocks.ReinforcedPlasticBlock,
|
||||
MekanismBlocks.SlickPlasticBlock, MekanismBlocks.PlasticFence);
|
||||
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemColor() {
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex)
|
||||
{
|
||||
if(MachineType.get(stack) == MachineType.FLUID_TANK)
|
||||
{
|
||||
EnumColor color = ((ItemBlockMachine)stack.getItem()).getBaseTier(stack).getColor();
|
||||
|
||||
return (int)(color.getColor(0)*255) << 16 | (int)(color.getColor(1)*255) << 8 | (int)(color.getColor(2)*255);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}, MekanismBlocks.MachineBlock, MekanismBlocks.MachineBlock2, MekanismBlocks.MachineBlock3);
|
||||
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemColor() {
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex)
|
||||
{
|
||||
if(stack.getItem() instanceof ItemBlockPlastic)
|
||||
{
|
||||
EnumDyeColor dyeColor = EnumDyeColor.byMetadata(stack.getItemDamage()&15);
|
||||
EnumColor dye = EnumColor.DYES[dyeColor.getDyeDamage()];
|
||||
|
||||
return (int)(dye.getColor(0)*255) << 16 | (int)(dye.getColor(1)*255) << 8 | (int)(dye.getColor(2)*255);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}, MekanismBlocks.PlasticBlock, MekanismBlocks.GlowPlasticBlock, MekanismBlocks.RoadPlasticBlock, MekanismBlocks.ReinforcedPlasticBlock,
|
||||
MekanismBlocks.SlickPlasticBlock, MekanismBlocks.PlasticFence);
|
||||
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.ObsidianTNT), 0, new ModelResourceLocation("mekanism:ObsidianTNT", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.SaltBlock), 0, new ModelResourceLocation("mekanism:SaltBlock", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(MekanismBlocks.CardboardBox), 0, new ModelResourceLocation("mekanism:CardboardBox", "storage=false"));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mekanism.client.render.obj;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.vecmath.Matrix4f;
|
||||
@@ -12,13 +13,18 @@ import mekanism.common.multipart.PartGlowPanel;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
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.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.IPerspectiveAwareModel;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
@@ -27,19 +33,22 @@ import net.minecraftforge.client.model.obj.OBJModel.OBJBakedModel;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class GlowPanelModel extends OBJBakedModelBase implements ISmartMultipartModel
|
||||
public class GlowPanelModel extends OBJBakedModelBase
|
||||
{
|
||||
private static Map<Integer, GlowPanelModel> glowPanelCache = new HashMap<Integer, GlowPanelModel>();
|
||||
private static Map<Integer, List<BakedQuad>> glowPanelCache = new HashMap<Integer, List<BakedQuad>>();
|
||||
private static Map<Integer, GlowPanelModel> glowPanelItemCache = new HashMap<Integer, GlowPanelModel>();
|
||||
|
||||
private IBlockState tempState;
|
||||
private ItemStack tempStack;
|
||||
|
||||
private GlowPanelOverride override = new GlowPanelOverride();
|
||||
|
||||
public GlowPanelModel(IBakedModel base, OBJModel model, IModelState state, VertexFormat format, ImmutableMap<String, TextureAtlasSprite> textures, HashMap<TransformType, Matrix4f> transform)
|
||||
{
|
||||
super(base, model, state, format, textures, transform);
|
||||
@@ -66,59 +75,78 @@ public class GlowPanelModel extends OBJBakedModelBase implements ISmartMultipart
|
||||
return EnumColor.WHITE;
|
||||
}
|
||||
|
||||
private class GlowPanelOverride extends ItemOverrideList
|
||||
{
|
||||
public GlowPanelOverride()
|
||||
{
|
||||
super(Lists.newArrayList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
|
||||
{
|
||||
if(glowPanelItemCache.containsKey(stack.getItemDamage()))
|
||||
{
|
||||
return glowPanelItemCache.get(stack.getItemDamage());
|
||||
}
|
||||
|
||||
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
|
||||
builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE);
|
||||
TextureAtlasSprite missing = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(new ResourceLocation("missingno").toString());
|
||||
|
||||
for(String s : getModel().getMatLib().getMaterialNames())
|
||||
{
|
||||
TextureAtlasSprite sprite = null;
|
||||
|
||||
if(sprite == null)
|
||||
{
|
||||
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(getModel().getMatLib().getMaterial(s).getTexture().getTextureLocation().toString());
|
||||
}
|
||||
|
||||
if(sprite == null)
|
||||
{
|
||||
sprite = missing;
|
||||
}
|
||||
|
||||
builder.put(s, sprite);
|
||||
}
|
||||
|
||||
builder.put("missingno", missing);
|
||||
GlowPanelModel bakedModel = new GlowPanelModel(baseModel, getModel(), getState(), vertexFormat, builder.build(), transformationMap);
|
||||
bakedModel.tempStack = stack;
|
||||
glowPanelItemCache.put(stack.getItemDamage(), bakedModel);
|
||||
|
||||
return bakedModel;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OBJBakedModel handlePartState(IBlockState state)
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
int hash = PartGlowPanel.hash((IExtendedBlockState)state);
|
||||
return override;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand)
|
||||
{
|
||||
if(side != null)
|
||||
{
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
int hash = PartGlowPanel.hash((IExtendedBlockState)state);
|
||||
EnumColor color = ((IExtendedBlockState)state).getValue(ColorProperty.INSTANCE).color;
|
||||
|
||||
if(!glowPanelCache.containsKey(hash))
|
||||
{
|
||||
GlowPanelModel model = new GlowPanelModel(baseModel, getModel(), getState(), getFormat(), textureMap, transformationMap);
|
||||
GlowPanelModel model = new GlowPanelModel(baseModel, getModel(), getState(), vertexFormat, textureMap, transformationMap);
|
||||
model.tempState = state;
|
||||
glowPanelCache.put(hash, model);
|
||||
glowPanelCache.put(hash, model.getQuads(state, side, rand));
|
||||
}
|
||||
|
||||
return glowPanelCache.get(hash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(ItemStack stack)
|
||||
{
|
||||
if(glowPanelItemCache.containsKey(stack.getItemDamage()))
|
||||
{
|
||||
return glowPanelItemCache.get(stack.getItemDamage());
|
||||
}
|
||||
|
||||
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
|
||||
builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE);
|
||||
TextureAtlasSprite missing = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(new ResourceLocation("missingno").toString());
|
||||
|
||||
for(String s : getModel().getMatLib().getMaterialNames())
|
||||
{
|
||||
TextureAtlasSprite sprite = null;
|
||||
|
||||
if(sprite == null)
|
||||
{
|
||||
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(getModel().getMatLib().getMaterial(s).getTexture().getTextureLocation().toString());
|
||||
}
|
||||
|
||||
if(sprite == null)
|
||||
{
|
||||
sprite = missing;
|
||||
}
|
||||
|
||||
builder.put(s, sprite);
|
||||
}
|
||||
|
||||
builder.put("missingno", missing);
|
||||
GlowPanelModel bakedModel = new GlowPanelModel(baseModel, getModel(), getState(), getFormat(), builder.build(), transformationMap);
|
||||
bakedModel.tempStack = stack;
|
||||
glowPanelItemCache.put(stack.getItemDamage(), bakedModel);
|
||||
|
||||
return bakedModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getOverrideColor(Face f, String groupName)
|
||||
{
|
||||
@@ -149,15 +177,8 @@ public class GlowPanelModel extends OBJBakedModelBase implements ISmartMultipart
|
||||
else if(cameraTransformType == TransformType.THIRD_PERSON_RIGHT_HAND)
|
||||
{
|
||||
GlStateManager.translate(0.0F, -0.1F, 0.0F);
|
||||
|
||||
if(thirdPersonTransform == null)
|
||||
{
|
||||
thirdPersonTransform = ImmutablePair.of(this, CTMModelFactory.DEFAULT_BLOCK_THIRD_PERSON_MATRIX);
|
||||
}
|
||||
|
||||
return thirdPersonTransform;
|
||||
}
|
||||
|
||||
return Pair.of(this, null);
|
||||
return Pair.of(this, CTMModelFactory.transforms.get(cameraTransformType).getMatrix());
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package mekanism.client.render.obj;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -50,8 +51,6 @@ public abstract class OBJBakedModelBase extends OBJBakedModel
|
||||
|
||||
protected HashMap<TransformType, Matrix4f> transformationMap = new HashMap<TransformType, Matrix4f>();
|
||||
|
||||
private Set<BakedQuad> bakedQuads;
|
||||
|
||||
public OBJBakedModelBase(IBakedModel base, OBJModel model, IModelState state, VertexFormat format, ImmutableMap<String, TextureAtlasSprite> textures, HashMap<TransformType, Matrix4f> transform)
|
||||
{
|
||||
model.super(model, state, format, textures);
|
||||
@@ -74,106 +73,104 @@ public abstract class OBJBakedModelBase extends OBJBakedModel
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
if(bakedQuads == null)
|
||||
List<BakedQuad> bakedQuads = new ArrayList<BakedQuad>();
|
||||
|
||||
Set<Face> faces = Collections.synchronizedSet(new LinkedHashSet<Face>());
|
||||
Optional<TRSRTransformation> transform = Optional.absent();
|
||||
Map<Face, String> groupNameMap = new HashMap<Face, String>();
|
||||
|
||||
for(Group g : getModel().getMatLib().getGroups().values())
|
||||
{
|
||||
bakedQuads = Collections.synchronizedSet(new LinkedHashSet<BakedQuad>());
|
||||
Set<Face> faces = Collections.synchronizedSet(new LinkedHashSet<Face>());
|
||||
Optional<TRSRTransformation> transform = Optional.absent();
|
||||
Map<Face, String> groupNameMap = new HashMap<Face, String>();
|
||||
|
||||
for(Group g : getModel().getMatLib().getGroups().values())
|
||||
if(getState() instanceof OBJState)
|
||||
{
|
||||
if(getState() instanceof OBJState)
|
||||
OBJState state = (OBJState)getState();
|
||||
|
||||
if(state.parent != null)
|
||||
{
|
||||
OBJState state = (OBJState)getState();
|
||||
|
||||
if(state.parent != null)
|
||||
{
|
||||
transform = state.parent.apply(Optional.absent());
|
||||
}
|
||||
|
||||
updateStateVisibilityMap(state);
|
||||
|
||||
if(state.getGroupsWithVisibility(true).contains(g.getName()))
|
||||
{
|
||||
Set<Face> groupFaces = g.applyTransform(transform);
|
||||
|
||||
for(Face f : groupFaces)
|
||||
{
|
||||
groupNameMap.put(f, g.getName());
|
||||
faces.add(f);
|
||||
}
|
||||
}
|
||||
transform = state.parent.apply(Optional.absent());
|
||||
}
|
||||
else {
|
||||
transform = getState().apply(Optional.absent());
|
||||
Set<Face> groupFaces = g.applyTransform(transform);
|
||||
|
||||
for(Face f : groupFaces)
|
||||
|
||||
updateStateVisibilityMap(state);
|
||||
|
||||
if(state.getGroupsWithVisibility(true).contains(g.getName()))
|
||||
{
|
||||
Set<Face> groupFaces = g.applyTransform(transform);
|
||||
|
||||
for(Face f : groupFaces)
|
||||
{
|
||||
groupNameMap.put(f, g.getName());
|
||||
faces.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(Face f : faces)
|
||||
{
|
||||
String groupName = groupNameMap.get(f);
|
||||
|
||||
if(getOverrideTexture(f, groupName) != null)
|
||||
else {
|
||||
transform = getState().apply(Optional.absent());
|
||||
Set<Face> groupFaces = g.applyTransform(transform);
|
||||
|
||||
for(Face f : groupFaces)
|
||||
{
|
||||
tempSprite = getOverrideTexture(f, groupName);
|
||||
groupNameMap.put(f, g.getName());
|
||||
faces.add(f);
|
||||
}
|
||||
else if(getModel().getMatLib().getMaterial(f.getMaterialName()).isWhite())
|
||||
{
|
||||
for(Vertex v : f.getVertices())
|
||||
{
|
||||
if(!v.getMaterial().equals(getModel().getMatLib().getMaterial(v.getMaterial().getName())))
|
||||
{
|
||||
v.setMaterial(getModel().getMatLib().getMaterial(v.getMaterial().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
tempSprite = ModelLoader.White.INSTANCE;
|
||||
}
|
||||
else {
|
||||
tempSprite = textureMap.get(f.getMaterialName());
|
||||
}
|
||||
|
||||
float[] color = new float[] {1, 1, 1, 1};
|
||||
|
||||
if(getOverrideColor(f, groupName) != null)
|
||||
{
|
||||
color = getOverrideColor(f, groupName);
|
||||
}
|
||||
|
||||
EnumFacing facing = EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z);
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(vertexFormat);
|
||||
builder.setContractUVs(true);
|
||||
builder.setQuadOrientation(facing);
|
||||
builder.setTexture(tempSprite);
|
||||
builder.setQuadTint(0);
|
||||
|
||||
Normal faceNormal = f.getNormal();
|
||||
boolean rotate = shouldRotate(f, groupName);
|
||||
|
||||
putVertexData(builder, f.getVertices()[0], faceNormal, TextureCoordinate.getDefaultUVs()[0], tempSprite, vertexFormat, color);
|
||||
putVertexData(builder, f.getVertices()[1], faceNormal, TextureCoordinate.getDefaultUVs()[1], tempSprite, vertexFormat, color);
|
||||
putVertexData(builder, f.getVertices()[2], faceNormal, TextureCoordinate.getDefaultUVs()[2], tempSprite, vertexFormat, color);
|
||||
putVertexData(builder, f.getVertices()[3], faceNormal, TextureCoordinate.getDefaultUVs()[3], tempSprite, vertexFormat, color);
|
||||
|
||||
BakedQuad quad = builder.build();
|
||||
|
||||
if(rotate)
|
||||
{
|
||||
quad = MekanismRenderer.rotate(quad, 1);
|
||||
}
|
||||
|
||||
bakedQuads.add(quad);
|
||||
}
|
||||
}
|
||||
|
||||
for(Face f : faces)
|
||||
{
|
||||
String groupName = groupNameMap.get(f);
|
||||
|
||||
if(getOverrideTexture(f, groupName) != null)
|
||||
{
|
||||
tempSprite = getOverrideTexture(f, groupName);
|
||||
}
|
||||
else if(getModel().getMatLib().getMaterial(f.getMaterialName()).isWhite())
|
||||
{
|
||||
for(Vertex v : f.getVertices())
|
||||
{
|
||||
if(!v.getMaterial().equals(getModel().getMatLib().getMaterial(v.getMaterial().getName())))
|
||||
{
|
||||
v.setMaterial(getModel().getMatLib().getMaterial(v.getMaterial().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
tempSprite = ModelLoader.White.INSTANCE;
|
||||
}
|
||||
else {
|
||||
tempSprite = textureMap.get(f.getMaterialName());
|
||||
}
|
||||
|
||||
float[] color = new float[] {1, 1, 1, 1};
|
||||
|
||||
if(getOverrideColor(f, groupName) != null)
|
||||
{
|
||||
color = getOverrideColor(f, groupName);
|
||||
}
|
||||
|
||||
EnumFacing facing = EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z);
|
||||
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(vertexFormat);
|
||||
builder.setContractUVs(true);
|
||||
builder.setQuadOrientation(facing);
|
||||
builder.setTexture(tempSprite);
|
||||
builder.setQuadTint(0);
|
||||
|
||||
Normal faceNormal = f.getNormal();
|
||||
boolean rotate = shouldRotate(f, groupName);
|
||||
|
||||
putVertexData(builder, f.getVertices()[0], faceNormal, TextureCoordinate.getDefaultUVs()[0], tempSprite, vertexFormat, color);
|
||||
putVertexData(builder, f.getVertices()[1], faceNormal, TextureCoordinate.getDefaultUVs()[1], tempSprite, vertexFormat, color);
|
||||
putVertexData(builder, f.getVertices()[2], faceNormal, TextureCoordinate.getDefaultUVs()[2], tempSprite, vertexFormat, color);
|
||||
putVertexData(builder, f.getVertices()[3], faceNormal, TextureCoordinate.getDefaultUVs()[3], tempSprite, vertexFormat, color);
|
||||
|
||||
BakedQuad quad = builder.build();
|
||||
|
||||
if(rotate)
|
||||
{
|
||||
quad = MekanismRenderer.rotate(quad, 1);
|
||||
}
|
||||
|
||||
bakedQuads.add(quad);
|
||||
}
|
||||
|
||||
List<BakedQuad> quadList = Collections.synchronizedList(Lists.newArrayList(bakedQuads));
|
||||
|
||||
return quadList;
|
||||
|
||||
@@ -14,16 +14,20 @@ import mekanism.common.multipart.ConnectionProperty;
|
||||
import mekanism.common.multipart.PartSidedPipe;
|
||||
import mekanism.common.multipart.PartSidedPipe.ConnectionType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumFacing.Axis;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.client.model.obj.OBJModel.Face;
|
||||
@@ -33,11 +37,13 @@ import net.minecraftforge.client.model.obj.OBJModel.OBJState;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class TransmitterModel extends OBJBakedModelBase implements ISmartMultipartModel
|
||||
public class TransmitterModel extends OBJBakedModelBase
|
||||
{
|
||||
private Map<Integer, TransmitterModel> modelCache = new HashMap<Integer, TransmitterModel>();
|
||||
private Map<Integer, List<BakedQuad>> modelCache = new HashMap<Integer, List<BakedQuad>>();
|
||||
private TransmitterModel itemCache;
|
||||
|
||||
private IBlockState tempState;
|
||||
@@ -48,14 +54,54 @@ public class TransmitterModel extends OBJBakedModelBase implements ISmartMultipa
|
||||
private static TextureAtlasSprite transporter_side;
|
||||
private static TextureAtlasSprite transporter_side_color;
|
||||
|
||||
private TransmitterOverride override = new TransmitterOverride();
|
||||
|
||||
public TransmitterModel(IBakedModel base, OBJModel model, IModelState state, VertexFormat format, ImmutableMap<String, TextureAtlasSprite> textures, HashMap<TransformType, Matrix4f> transform)
|
||||
{
|
||||
super(base, model, state, format, textures, transform);
|
||||
}
|
||||
|
||||
private class TransmitterOverride extends ItemOverrideList
|
||||
{
|
||||
public TransmitterOverride()
|
||||
{
|
||||
super(Lists.newArrayList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
|
||||
{
|
||||
if(itemCache == null)
|
||||
{
|
||||
List<String> visible = new ArrayList<String>();
|
||||
|
||||
for(EnumFacing side : EnumFacing.values())
|
||||
{
|
||||
visible.add(side.getName() + (side.getAxis() == Axis.Y ? "NORMAL" : "NONE"));
|
||||
}
|
||||
|
||||
itemCache = new TransmitterModel(baseModel, getModel(), new OBJState(visible, true), vertexFormat, textureMap, transformationMap);
|
||||
itemCache.tempStack = stack;
|
||||
}
|
||||
|
||||
return itemCache;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handlePartState(IBlockState state)
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return override;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand)
|
||||
{
|
||||
if(side != null)
|
||||
{
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
IExtendedBlockState extended = (IExtendedBlockState)state;
|
||||
BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
|
||||
ColorProperty colorProp = extended.getValue(ColorProperty.INSTANCE);
|
||||
@@ -82,33 +128,14 @@ public class TransmitterModel extends OBJBakedModelBase implements ISmartMultipa
|
||||
|
||||
if(!modelCache.containsKey(hash))
|
||||
{
|
||||
TransmitterModel model = new TransmitterModel(baseModel, getModel(), obj, getFormat(), textureMap, transformationMap);
|
||||
TransmitterModel model = new TransmitterModel(baseModel, getModel(), obj, vertexFormat, textureMap, transformationMap);
|
||||
model.tempState = state;
|
||||
modelCache.put(hash, model);
|
||||
modelCache.put(hash, model.getQuads(state, side, rand));
|
||||
}
|
||||
|
||||
return modelCache.get(hash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(ItemStack stack)
|
||||
{
|
||||
if(itemCache == null)
|
||||
{
|
||||
List<String> visible = new ArrayList<String>();
|
||||
|
||||
for(EnumFacing side : EnumFacing.values())
|
||||
{
|
||||
visible.add(side.getName() + (side.getAxis() == Axis.Y ? "NORMAL" : "NONE"));
|
||||
}
|
||||
|
||||
itemCache = new TransmitterModel(baseModel, getModel(), new OBJState(visible, true), getFormat(), textureMap, transformationMap);
|
||||
itemCache.tempStack = stack;
|
||||
}
|
||||
|
||||
return itemCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getOverrideColor(Face f, String groupName)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ import mekanism.common.frequency.FrequencyManager;
|
||||
import mekanism.common.multiblock.MultiblockManager;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkGenerator;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent.WorldTickEvent;
|
||||
@@ -110,7 +111,7 @@ public class CommonWorldTickHandler
|
||||
long zSeed = fmlRandom.nextLong() >> 2 + 1L;
|
||||
fmlRandom.setSeed((xSeed*nextChunk.chunkXPos + zSeed*nextChunk.chunkZPos) ^ world.getSeed());
|
||||
|
||||
Mekanism.genHandler.generate(fmlRandom, nextChunk.chunkXPos, nextChunk.chunkZPos, world, world.getChunkProvider(), world.getChunkProvider());
|
||||
Mekanism.genHandler.generate(fmlRandom, nextChunk.chunkXPos, nextChunk.chunkZPos, world, (IChunkGenerator)world.getChunkProvider(), world.getChunkProvider());
|
||||
Mekanism.logger.info("[Mekanism] Regenerating ores at chunk " + nextChunk);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ public final class MekanismSounds
|
||||
public static final SoundEvent POP = getRegisteredSoundEvent("mekanism:etc.Pop");
|
||||
public static final SoundEvent DING = getRegisteredSoundEvent("mekanism:etc.Ding");
|
||||
public static final SoundEvent HYDRAULIC = getRegisteredSoundEvent("mekanism:etc.Hydraulic");
|
||||
public static final SoundEvent CLICK = getRegisteredSoundEvent("mekanism:etc.Click");
|
||||
|
||||
private static SoundEvent getRegisteredSoundEvent(String id)
|
||||
{
|
||||
|
||||
@@ -55,6 +55,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
@@ -419,7 +420,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
BasicBlockType type = BasicBlockType.get(state);
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
@@ -469,15 +470,15 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
{
|
||||
TileEntityBin bin = (TileEntityBin)tile;
|
||||
|
||||
if(entityplayer.getCurrentEquippedItem() != null && MekanismUtils.hasUsableWrench(entityplayer, pos))
|
||||
if(stack != null && MekanismUtils.hasUsableWrench(entityplayer, pos))
|
||||
{
|
||||
if(!world.isRemote)
|
||||
{
|
||||
Item tool = entityplayer.getCurrentEquippedItem().getItem();
|
||||
Item tool = stack.getItem();
|
||||
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
dismantleBlock(world, pos, false);
|
||||
dismantleBlock(state, world, pos, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -499,12 +500,12 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
{
|
||||
if(bin.getItemCount() < bin.tier.storage)
|
||||
{
|
||||
if(bin.addTicks == 0 && entityplayer.getCurrentEquippedItem() != null)
|
||||
if(bin.addTicks == 0 && stack != null)
|
||||
{
|
||||
if(entityplayer.getCurrentEquippedItem() != null)
|
||||
if(stack != null)
|
||||
{
|
||||
ItemStack remain = bin.add(entityplayer.getCurrentEquippedItem());
|
||||
entityplayer.setCurrentItemOrArmor(0, remain);
|
||||
ItemStack remain = bin.add(stack);
|
||||
entityplayer.setHeldItem(hand, remain);
|
||||
bin.addTicks = 5;
|
||||
}
|
||||
}
|
||||
@@ -541,7 +542,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
return true;
|
||||
}
|
||||
|
||||
return ((IMultiblock)world.getTileEntity(pos)).onActivate(entityplayer);
|
||||
return ((IMultiblock)world.getTileEntity(pos)).onActivate(entityplayer, hand, stack);
|
||||
}
|
||||
else if(tile instanceof IStructuralMultiblock)
|
||||
{
|
||||
@@ -550,7 +551,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
return true;
|
||||
}
|
||||
|
||||
return ((IStructuralMultiblock)world.getTileEntity(pos)).onActivate(entityplayer);
|
||||
return ((IStructuralMultiblock)world.getTileEntity(pos)).onActivate(entityplayer, hand, stack);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -569,10 +570,8 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
public static boolean manageInventory(EntityPlayer player, TileEntityDynamicTank tileEntity)
|
||||
public static boolean manageInventory(EntityPlayer player, TileEntityDynamicTank tileEntity, EnumHand hand, ItemStack itemStack)
|
||||
{
|
||||
ItemStack itemStack = player.getCurrentEquippedItem();
|
||||
|
||||
if(itemStack != null && tileEntity.structure != null)
|
||||
{
|
||||
if(FluidContainerRegistry.isEmptyContainer(itemStack))
|
||||
@@ -613,7 +612,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
}
|
||||
else if(itemStack.stackSize == 1)
|
||||
{
|
||||
player.setCurrentItemOrArmor(0, filled);
|
||||
player.setHeldItem(hand, filled);
|
||||
|
||||
tileEntity.structure.fluidStored.amount -= FluidContainerRegistry.getFluidForFilledItem(filled).amount;
|
||||
|
||||
@@ -647,7 +646,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
{
|
||||
if(itemStack.stackSize == 1)
|
||||
{
|
||||
player.setCurrentItemOrArmor(0, containerItem);
|
||||
player.setHeldItem(hand, containerItem);
|
||||
filled = true;
|
||||
}
|
||||
else {
|
||||
@@ -664,7 +663,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock
|
||||
|
||||
if(itemStack.stackSize == 0)
|
||||
{
|
||||
player.setCurrentItemOrArmor(0, null);
|
||||
player.setHeldItem(hand, null);
|
||||
}
|
||||
|
||||
filled = true;
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -64,7 +65,7 @@ public class BlockCardboardBox extends BlockContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if(!world.isRemote && entityplayer.isSneaking())
|
||||
{
|
||||
|
||||
@@ -33,6 +33,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
@@ -184,7 +185,7 @@ public class BlockEnergyCube extends BlockContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if(world.isRemote)
|
||||
{
|
||||
@@ -193,9 +194,9 @@ public class BlockEnergyCube extends BlockContainer
|
||||
|
||||
TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getTileEntity(pos);
|
||||
|
||||
if(entityplayer.getCurrentEquippedItem() != null)
|
||||
if(stack != null)
|
||||
{
|
||||
Item tool = entityplayer.getCurrentEquippedItem().getItem();
|
||||
Item tool = stack.getItem();
|
||||
|
||||
if(MekanismUtils.hasUsableWrench(entityplayer, pos))
|
||||
{
|
||||
@@ -203,14 +204,14 @@ public class BlockEnergyCube extends BlockContainer
|
||||
{
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
dismantleBlock(world, pos, false);
|
||||
dismantleBlock(state, world, pos, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(MekanismUtils.isBCWrench(tool))
|
||||
{
|
||||
((IToolWrench) tool).wrenchUsed(entityplayer, pos);
|
||||
((IToolWrench)tool).wrenchUsed(entityplayer, pos);
|
||||
}
|
||||
|
||||
int change = tileEntity.facing.rotateAround(side.getAxis()).ordinal();
|
||||
|
||||
@@ -29,6 +29,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
@@ -38,10 +40,11 @@ import buildcraft.api.tools.IToolWrench;
|
||||
|
||||
public class BlockGasTank extends BlockContainer
|
||||
{
|
||||
private static final AxisAlignedBB TANK_BOUNDS = new AxisAlignedBB(0.2F, 0.0F, 0.2F, 0.8F, 1.0F, 0.8F);
|
||||
|
||||
public BlockGasTank()
|
||||
{
|
||||
super(Material.IRON);
|
||||
setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 1.0F, 0.8F);
|
||||
setHardness(3.5F);
|
||||
setResistance(8F);
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
@@ -131,7 +134,7 @@ public class BlockGasTank extends BlockContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if(world.isRemote)
|
||||
{
|
||||
@@ -140,9 +143,9 @@ public class BlockGasTank extends BlockContainer
|
||||
|
||||
TileEntityGasTank tileEntity = (TileEntityGasTank)world.getTileEntity(pos);
|
||||
|
||||
if(entityplayer.getCurrentEquippedItem() != null)
|
||||
if(stack != null)
|
||||
{
|
||||
Item tool = entityplayer.getCurrentEquippedItem().getItem();
|
||||
Item tool = stack.getItem();
|
||||
|
||||
if(MekanismUtils.hasUsableWrench(entityplayer, pos))
|
||||
{
|
||||
@@ -150,7 +153,7 @@ public class BlockGasTank extends BlockContainer
|
||||
{
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
dismantleBlock(world, pos, false);
|
||||
dismantleBlock(state, world, pos, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -254,6 +257,12 @@ public class BlockGasTank extends BlockContainer
|
||||
{
|
||||
return EnumBlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
return TANK_BOUNDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta)
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.MekanismConfig.client;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
@@ -69,6 +68,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -134,6 +134,9 @@ import buildcraft.api.tools.IToolWrench;
|
||||
public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
{
|
||||
public CTMData[] ctmData = new CTMData[16];
|
||||
|
||||
private static final AxisAlignedBB CHARGEPAD_BOUNDS = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 0.06F, 1.0F);
|
||||
private static final AxisAlignedBB TANK_BOUNDS = new AxisAlignedBB(0.125F, 0.0F, 0.125F, 0.875F, 1.0F, 0.875F);
|
||||
|
||||
public BlockMachine()
|
||||
{
|
||||
@@ -445,7 +448,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if(world.isRemote)
|
||||
{
|
||||
@@ -455,9 +458,9 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos);
|
||||
int metadata = state.getBlock().getMetaFromState(state);
|
||||
|
||||
if(entityplayer.getCurrentEquippedItem() != null)
|
||||
if(stack != null)
|
||||
{
|
||||
Item tool = entityplayer.getCurrentEquippedItem().getItem();
|
||||
Item tool = stack.getItem();
|
||||
|
||||
if(MekanismUtils.hasUsableWrench(entityplayer, pos))
|
||||
{
|
||||
@@ -465,7 +468,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
{
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
dismantleBlock(world, pos, false);
|
||||
dismantleBlock(state, world, pos, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -533,9 +536,9 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
{
|
||||
if(SecurityUtils.canAccess(entityplayer, tileEntity))
|
||||
{
|
||||
if(entityplayer.getCurrentEquippedItem() != null && FluidContainerRegistry.isContainer(entityplayer.getCurrentEquippedItem()))
|
||||
if(stack != null && FluidContainerRegistry.isContainer(stack))
|
||||
{
|
||||
if(manageInventory(entityplayer, (TileEntityFluidTank)tileEntity))
|
||||
if(manageInventory(entityplayer, (TileEntityFluidTank)tileEntity, hand, stack))
|
||||
{
|
||||
entityplayer.inventory.markDirty();
|
||||
return true;
|
||||
@@ -684,7 +687,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
|
||||
EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, getPickBlock(null, world, pos, player));
|
||||
EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, getPickBlock(state, null, world, pos, player));
|
||||
|
||||
world.spawnEntityInWorld(entityItem);
|
||||
}
|
||||
@@ -692,10 +695,8 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
return world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
private boolean manageInventory(EntityPlayer player, TileEntityFluidTank tileEntity)
|
||||
private boolean manageInventory(EntityPlayer player, TileEntityFluidTank tileEntity, EnumHand hand, ItemStack itemStack)
|
||||
{
|
||||
ItemStack itemStack = player.getCurrentEquippedItem();
|
||||
|
||||
if(itemStack != null)
|
||||
{
|
||||
if(FluidContainerRegistry.isEmptyContainer(itemStack))
|
||||
@@ -724,7 +725,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
}
|
||||
else if(itemStack.stackSize == 1)
|
||||
{
|
||||
player.setCurrentItemOrArmor(0, filled);
|
||||
player.setHeldItem(hand, filled);
|
||||
|
||||
tileEntity.fluidTank.drain(FluidContainerRegistry.getFluidForFilledItem(filled).amount, true);
|
||||
|
||||
@@ -758,7 +759,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
{
|
||||
if(itemStack.stackSize == 1)
|
||||
{
|
||||
player.setCurrentItemOrArmor(0, containerItem);
|
||||
player.setHeldItem(hand, containerItem);
|
||||
filled = true;
|
||||
}
|
||||
else {
|
||||
@@ -775,7 +776,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
|
||||
if(itemStack.stackSize == 0)
|
||||
{
|
||||
player.setCurrentItemOrArmor(0, null);
|
||||
player.setHeldItem(hand, null);
|
||||
}
|
||||
|
||||
filled = true;
|
||||
@@ -918,25 +919,6 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorMultiplier(IBlockAccess world, BlockPos pos, int renderPass)
|
||||
{
|
||||
return getRenderColor(getActualState(world.getBlockState(pos), world, pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderColor(IBlockState state)
|
||||
{
|
||||
if(state.getValue(getMachineBlock().getProperty()) == MachineType.FLUID_TANK)
|
||||
{
|
||||
EnumColor color = state.getValue(BlockStateMachine.tierProperty).getColor();
|
||||
|
||||
return (int)(color.getColor(0)*255) << 16 | (int)(color.getColor(1)*255) << 8 | (int)(color.getColor(2)*255);
|
||||
}
|
||||
|
||||
return super.getRenderColor(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side)
|
||||
@@ -974,22 +956,18 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state));
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case CHARGEPAD:
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.06F, 1.0F);
|
||||
break;
|
||||
return CHARGEPAD_BOUNDS;
|
||||
case FLUID_TANK:
|
||||
setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 1.0F, 0.875F);
|
||||
break;
|
||||
return TANK_BOUNDS;
|
||||
default:
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
break;
|
||||
return super.getBoundingBox(state, world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1002,8 +980,6 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, World world, BlockPos pos)
|
||||
{
|
||||
setBlockBoundsBasedOnState(world, pos);
|
||||
|
||||
if(world.getTileEntity(pos) instanceof TileEntityChargepad)
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -10,7 +10,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
@@ -75,16 +77,17 @@ public class BlockObsidianTNT extends Block
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if(entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().getItem() == Items.FLINT_AND_STEEL)
|
||||
if(stack != null && stack.getItem() == Items.FLINT_AND_STEEL)
|
||||
{
|
||||
explode(world, pos);
|
||||
world.setBlockToAir(pos);
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return super.onBlockActivated(world, pos, state, entityplayer, side, hitX, hitY, hitZ);
|
||||
return super.onBlockActivated(world, pos, state, entityplayer, hand, stack, side, hitX, hitY, hitZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package mekanism.common.block;
|
||||
|
||||
import static mekanism.common.block.states.BlockStatePlastic.colorProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
@@ -51,13 +49,13 @@ public class BlockPlastic extends Block
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return getDefaultState().withProperty(colorProperty, EnumDyeColor.byMetadata(meta));
|
||||
return getDefaultState().withProperty(BlockStatePlastic.colorProperty, EnumDyeColor.byMetadata(meta));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return state.getValue(colorProperty).getMetadata();
|
||||
return state.getValue(BlockStatePlastic.colorProperty).getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,21 +88,6 @@ public class BlockPlastic extends Block
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorMultiplier(IBlockAccess world, BlockPos pos, int renderPass)
|
||||
{
|
||||
return getRenderColor(world.getBlockState(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderColor(IBlockState state)
|
||||
{
|
||||
EnumDyeColor color = state.getValue(colorProperty);
|
||||
EnumColor dye = EnumColor.DYES[color.getDyeDamage()];
|
||||
|
||||
return (int)(dye.getColor(0)*255) << 16 | (int)(dye.getColor(1)*255) << 8 | (int)(dye.getColor(2)*255);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
|
||||
@@ -18,8 +18,6 @@ import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -59,21 +57,6 @@ public class BlockPlasticFence extends BlockFence
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorMultiplier(IBlockAccess world, BlockPos pos, int renderPass)
|
||||
{
|
||||
return getRenderColor(world.getBlockState(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderColor(IBlockState state)
|
||||
{
|
||||
EnumDyeColor color = state.getValue(colorProperty);
|
||||
EnumColor dye = EnumColor.DYES[color.getDyeDamage()];
|
||||
|
||||
return (int)(dye.getColor(0)*255) << 16 | (int)(dye.getColor(1)*255) << 8 | (int)(dye.getColor(2)*255);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state)
|
||||
{
|
||||
|
||||
@@ -3,12 +3,14 @@ package mekanism.common.capabilities;
|
||||
import mekanism.api.IAlloyInteraction;
|
||||
import mekanism.common.capabilities.StorageHelper.NullStorage;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
|
||||
public class AlloyInteraction implements IAlloyInteraction
|
||||
{
|
||||
@Override
|
||||
public void onAlloyInteraction(EntityPlayer player, int tierOrdinal) {}
|
||||
public void onAlloyInteraction(EntityPlayer player, EnumHand hand, ItemStack stack, int tierOrdinal) {}
|
||||
|
||||
public static void register()
|
||||
{
|
||||
|
||||
@@ -262,7 +262,7 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
}
|
||||
|
||||
worldObj.playAuxSFXAtEntity(null, 2001, block.getPos(), Block.getIdFromBlock(b) + (b.getMetaFromState(state) << 12));
|
||||
worldObj.playEvent(null, 2001, block.getPos(), Block.getStateId(state));
|
||||
}
|
||||
|
||||
spawnParticlesAt(new Pos3D(block).translate(0.5, 0.5, 0.5));
|
||||
|
||||
@@ -41,7 +41,10 @@ import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.pathfinding.PathNavigateGround;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
@@ -311,7 +314,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine
|
||||
|
||||
if(worldObj.provider.getDimension() != homeLocation.dimensionId)
|
||||
{
|
||||
travelToDimension(homeLocation.dimensionId);
|
||||
changeDimension(homeLocation.dimensionId);
|
||||
}
|
||||
|
||||
setPositionAndUpdate(homeLocation.xCoord+0.5, homeLocation.yCoord+0.3, homeLocation.zCoord+0.5);
|
||||
@@ -374,13 +377,11 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean interact(EntityPlayer entityplayer)
|
||||
public EnumActionResult applyPlayerInteraction(EntityPlayer entityplayer, Vec3d vec, ItemStack stack, EnumHand hand)
|
||||
{
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
ItemStack itemStack = entityplayer.getCurrentEquippedItem();
|
||||
|
||||
if(itemStack != null && itemStack.getItem() instanceof ItemConfigurator)
|
||||
if(stack != null && stack.getItem() instanceof ItemConfigurator)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
@@ -389,15 +390,16 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine
|
||||
|
||||
setDead();
|
||||
|
||||
entityplayer.swingItem();
|
||||
return true;
|
||||
entityplayer.swingArm(hand);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
else {
|
||||
entityplayer.openGui(Mekanism.instance, 21, worldObj, getEntityId(), 0, 0);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return false;
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
public void drop()
|
||||
|
||||
@@ -7,7 +7,9 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -19,7 +21,7 @@ public class ItemAlloy extends ItemMekanism
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
@@ -29,12 +31,12 @@ public class ItemAlloy extends ItemMekanism
|
||||
{
|
||||
IAlloyInteraction interaction = MekanismUtils.getCapability(tile, Capabilities.ALLOY_INTERACTION_CAPABILITY, side);
|
||||
int ordinal = stack.getItem() == MekanismItems.EnrichedAlloy? 1 : (stack.getItem() == MekanismItems.ReinforcedAlloy ? 2 : 3);
|
||||
interaction.onAlloyInteraction(player, ordinal);
|
||||
interaction.onAlloyInteraction(player, hand, stack, ordinal);
|
||||
}
|
||||
|
||||
return true;
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return false;
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
}
|
||||
@@ -14,19 +14,22 @@ import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDirt;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.UseHoeEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||
|
||||
public class ItemAtomicDisassembler extends ItemEnergized
|
||||
{
|
||||
@@ -132,7 +135,7 @@ public class ItemAtomicDisassembler extends ItemEnergized
|
||||
Block block2 = coord.getBlock(player.worldObj);
|
||||
|
||||
block2.onBlockDestroyedByPlayer(player.worldObj, coord.getPos(), state);
|
||||
player.worldObj.playAuxSFXAtEntity(null, 2001, coord.getPos(), meta << 12);
|
||||
player.worldObj.playEvent(null, 2001, coord.getPos(), Block.getStateId(state));
|
||||
player.worldObj.setBlockToAir(coord.getPos());
|
||||
block2.breakBlock(player.worldObj, coord.getPos(), state);
|
||||
block2.dropBlockAsItem(player.worldObj, coord.getPos(), state, 0);
|
||||
@@ -152,7 +155,7 @@ public class ItemAtomicDisassembler extends ItemEnergized
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
|
||||
public ActionResult<ItemStack> onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer, EnumHand hand)
|
||||
{
|
||||
if(!world.isRemote && entityplayer.isSneaking())
|
||||
{
|
||||
@@ -160,19 +163,19 @@ public class ItemAtomicDisassembler extends ItemEnergized
|
||||
entityplayer.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.modeToggle") + " " + EnumColor.INDIGO + getModeName(itemstack) + EnumColor.AQUA + " (" + getEfficiency(itemstack) + ")"));
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if(!player.isSneaking())
|
||||
{
|
||||
if(!useHoe(stack, player, world, pos, side))
|
||||
if(useHoe(stack, player, world, pos, side) == EnumActionResult.FAIL)
|
||||
{
|
||||
if(world.getBlockState(pos).getBlock() != Blocks.FARMLAND)
|
||||
{
|
||||
return false;
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,60 +203,62 @@ public class ItemAtomicDisassembler extends ItemEnergized
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return false;
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
private boolean useHoe(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side)
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
private EnumActionResult useHoe(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing facing)
|
||||
{
|
||||
if(!player.canPlayerEdit(pos, side, stack) || (!player.capabilities.isCreativeMode && getEnergy(stack) < HOE_USAGE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
UseHoeEvent event = new UseHoeEvent(player, stack, world, pos);
|
||||
if(!playerIn.canPlayerEdit(pos.offset(facing), facing, stack))
|
||||
{
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
else {
|
||||
int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, playerIn, worldIn, pos);
|
||||
if(hook != 0) return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
|
||||
|
||||
if(MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
if(event.getResult() == Result.ALLOW)
|
||||
{
|
||||
setEnergy(stack, getEnergy(stack)-HOE_USAGE);
|
||||
return true;
|
||||
}
|
||||
if(facing != EnumFacing.DOWN && worldIn.isAirBlock(pos.up()))
|
||||
{
|
||||
if(block == Blocks.GRASS || block == Blocks.GRASS_PATH)
|
||||
{
|
||||
setBlock(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState());
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
Block block1 = world.getBlockState(pos).getBlock();
|
||||
boolean air = block1.isAir(world.getBlockState(pos.up()), world, pos.up());
|
||||
if(block == Blocks.DIRT)
|
||||
{
|
||||
switch((BlockDirt.DirtType)iblockstate.getValue(BlockDirt.VARIANT))
|
||||
{
|
||||
case DIRT:
|
||||
setBlock(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState());
|
||||
return EnumActionResult.SUCCESS;
|
||||
case COARSE_DIRT:
|
||||
setBlock(stack, playerIn, worldIn, pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(side != EnumFacing.DOWN && air && (block1 == Blocks.GRASS || block1 == Blocks.DIRT))
|
||||
{
|
||||
Block farm = Blocks.FARMLAND;
|
||||
world.playSoundEffect(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, farm.stepSound.getStepSound(), (farm.stepSound.getVolume() + 1.0F) / 2.0F, farm.stepSound.getFrequency() * 0.8F);
|
||||
|
||||
if(world.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
world.setBlockState(pos, farm.getDefaultState());
|
||||
|
||||
if(!player.capabilities.isCreativeMode)
|
||||
{
|
||||
setEnergy(stack, getEnergy(stack)-HOE_USAGE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setBlock(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
worldIn.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
|
||||
if(!worldIn.isRemote)
|
||||
{
|
||||
worldIn.setBlockState(pos, state, 11);
|
||||
stack.damageItem(1, player);
|
||||
}
|
||||
}
|
||||
|
||||
public int getEfficiency(ItemStack itemStack)
|
||||
{
|
||||
|
||||
@@ -396,19 +396,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(ItemStack stack, int renderPass)
|
||||
{
|
||||
if(MachineType.get(stack) == MachineType.FLUID_TANK)
|
||||
{
|
||||
EnumColor color = getBaseTier(stack).getColor();
|
||||
|
||||
return (int)(color.getColor(0)*255) << 16 | (int)(color.getColor(1)*255) << 8 | (int)(color.getColor(2)*255);
|
||||
}
|
||||
|
||||
return super.getColorFromItemStack(stack, renderPass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
|
||||
@@ -7,8 +7,6 @@ import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBlockPlastic extends ItemBlock
|
||||
{
|
||||
@@ -49,10 +47,4 @@ public class ItemBlockPlastic extends ItemBlock
|
||||
|
||||
return colourName + " " + super.getItemStackDisplayName(stack);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(ItemStack stack, int renderPass)
|
||||
{
|
||||
return metaBlock.getRenderColor(metaBlock.getStateFromMeta(stack.getMetadata()));
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
package mekanism.common.multiblock;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
public interface IMultiblock<T extends SynchronizedData<T>>
|
||||
{
|
||||
public T getSynchronizedData();
|
||||
|
||||
public boolean onActivate(EntityPlayer player);
|
||||
public boolean onActivate(EntityPlayer player, EnumHand hand, ItemStack stack);
|
||||
|
||||
public void doUpdate();
|
||||
}
|
||||
@@ -2,11 +2,13 @@ package mekanism.common.multiblock;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
public interface IStructuralMultiblock
|
||||
{
|
||||
public boolean onActivate(EntityPlayer player);
|
||||
public boolean onActivate(EntityPlayer player, EnumHand hand, ItemStack stack);
|
||||
|
||||
public boolean canInterface(TileEntity controller);
|
||||
|
||||
|
||||
@@ -296,7 +296,7 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
*/
|
||||
public boolean isViableNode(int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = new Coord4D(x, y, z, pointer.getWorld().provider.getDimensionId()).getTileEntity(pointer.getWorld());
|
||||
TileEntity tile = new Coord4D(x, y, z, pointer.getWorld().provider.getDimension()).getTileEntity(pointer.getWorld());
|
||||
|
||||
if(tile instanceof IStructuralMultiblock)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,10 @@ import mekanism.common.Tier;
|
||||
import mekanism.common.block.states.BlockStateMachine.MachineType;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
|
||||
public class MultipartMekanism implements IPartFactory
|
||||
@@ -193,4 +196,33 @@ public class MultipartMekanism implements IPartFactory
|
||||
dropItem(stack, multipart);
|
||||
}
|
||||
}
|
||||
|
||||
public static AxisAlignedBB rotate(AxisAlignedBB aabb, EnumFacing side)
|
||||
{
|
||||
Vec3d v1 = rotate(new Vec3d(aabb.minX, aabb.minY, aabb.minZ), side);
|
||||
Vec3d v2 = rotate(new Vec3d(aabb.maxX, aabb.maxY, aabb.maxZ), side);
|
||||
|
||||
return new AxisAlignedBB(v1.xCoord, v1.yCoord, v1.zCoord, v2.xCoord, v2.yCoord, v2.zCoord);
|
||||
}
|
||||
|
||||
public static Vec3d rotate(Vec3d vec, EnumFacing side)
|
||||
{
|
||||
switch(side)
|
||||
{
|
||||
case DOWN:
|
||||
return new Vec3d(vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
case UP:
|
||||
return new Vec3d(vec.xCoord, -vec.yCoord, -vec.zCoord);
|
||||
case NORTH:
|
||||
return new Vec3d(vec.xCoord, -vec.zCoord, vec.yCoord);
|
||||
case SOUTH:
|
||||
return new Vec3d(vec.xCoord, vec.zCoord, -vec.yCoord);
|
||||
case WEST:
|
||||
return new Vec3d(vec.yCoord, -vec.xCoord, vec.zCoord);
|
||||
case EAST:
|
||||
return new Vec3d(-vec.yCoord, vec.xCoord, vec.zCoord);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class PartGlowPanel extends Multipart implements INormallyOccludingPart
|
||||
|
||||
for(EnumFacing side : EnumFacing.VALUES)
|
||||
{
|
||||
bounds[side.ordinal()] = TransformationHelper.rotate(cuboid.offset(fromOrigin.xCoord, fromOrigin.yCoord, fromOrigin.zCoord), side).offset(-fromOrigin.xCoord, -fromOrigin.zCoord, -fromOrigin.zCoord);
|
||||
bounds[side.ordinal()] = MultipartMekanism.rotate(cuboid.offset(fromOrigin.xCoord, fromOrigin.yCoord, fromOrigin.zCoord), side).offset(-fromOrigin.xCoord, -fromOrigin.zCoord, -fromOrigin.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,9 @@ import mekanism.api.transmitters.IGridTransmitter;
|
||||
import mekanism.api.transmitters.TransmitterNetworkRegistry;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
@@ -134,7 +136,7 @@ public abstract class PartTransmitter<A, N extends DynamicNetwork<A, N>> extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAlloyInteraction(EntityPlayer player, int tierOrdinal)
|
||||
public void onAlloyInteraction(EntityPlayer player, EnumHand hand, ItemStack stack, int tierOrdinal)
|
||||
{
|
||||
if(getTransmitter().hasTransmitterNetwork())
|
||||
{
|
||||
@@ -182,11 +184,11 @@ public abstract class PartTransmitter<A, N extends DynamicNetwork<A, N>> extends
|
||||
{
|
||||
if(!player.capabilities.isCreativeMode)
|
||||
{
|
||||
player.getCurrentEquippedItem().stackSize--;
|
||||
stack.stackSize--;
|
||||
|
||||
if(player.getCurrentEquippedItem().stackSize == 0)
|
||||
if(stack.stackSize == 0)
|
||||
{
|
||||
player.setCurrentItemOrArmor(0, null);
|
||||
player.setHeldItem(hand, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,16 +198,26 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
||||
break;
|
||||
case ENERGY:
|
||||
dataStream.writeDouble(power);
|
||||
|
||||
break;
|
||||
case GAS:
|
||||
dataStream.writeInt(gasStack != null ? gasStack.getGas().getID() : -1);
|
||||
dataStream.writeInt(gasStack != null ? gasStack.amount : 0);
|
||||
dataStream.writeBoolean(didGasTransfer);
|
||||
|
||||
break;
|
||||
case FLUID:
|
||||
dataStream.writeInt(fluidStack != null ? fluidStack.getFluid().getID() : -1);
|
||||
dataStream.writeInt(fluidStack != null ? fluidStack.amount : 0);
|
||||
if(fluidStack != null)
|
||||
{
|
||||
PacketHandler.writeString(dataStream, FluidRegistry.getFluidName(fluidStack));
|
||||
dataStream.writeInt(fluidStack.amount);
|
||||
}
|
||||
else {
|
||||
dataStream.writeBoolean(false);
|
||||
}
|
||||
|
||||
dataStream.writeBoolean(didFluidTransfer);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -249,9 +259,16 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
||||
}
|
||||
else if(packetType == PacketType.FLUID)
|
||||
{
|
||||
int type = dataStream.readInt();
|
||||
fluidType = type != -1 ? FluidRegistry.getFluid(type) : null;
|
||||
amount = dataStream.readInt();
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
fluidType = FluidRegistry.getFluid(PacketHandler.readString(dataStream));
|
||||
amount = dataStream.readInt();
|
||||
}
|
||||
else {
|
||||
fluidType = null;
|
||||
amount = 0;
|
||||
}
|
||||
|
||||
didFluidTransfer = dataStream.readBoolean();
|
||||
|
||||
if(fluidType != null)
|
||||
|
||||
@@ -23,6 +23,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -173,7 +174,7 @@ public class TileEntityBoilerCasing extends TileEntityMultiblock<SynchronizedBoi
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivate(EntityPlayer player)
|
||||
public boolean onActivate(EntityPlayer player, EnumHand hand, ItemStack stack)
|
||||
{
|
||||
if(!player.isSneaking() && structure != null)
|
||||
{
|
||||
|
||||
@@ -21,10 +21,12 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -104,7 +106,14 @@ public class TileEntityChargepad extends TileEntityNoisyElectricBlock
|
||||
|
||||
if(clientActive != isActive)
|
||||
{
|
||||
worldObj.playSoundEffect(getPos().getX() + 0.5, getPos().getY() + 0.1, getPos().getZ() + 0.5, "random.click", 0.3F, isActive ? 0.6F : 0.5F);
|
||||
if(isActive)
|
||||
{
|
||||
worldObj.playSound((EntityPlayer)null, getPos().getX() + 0.5, getPos().getY() + 0.1, getPos().getZ() + 0.5, SoundEvents.BLOCK_STONE_PRESSPLATE_CLICK_ON, SoundCategory.BLOCKS, 0.3F, 0.8F);
|
||||
}
|
||||
else {
|
||||
worldObj.playSound((EntityPlayer)null, getPos().getX() + 0.5, getPos().getY() + 0.1, getPos().getZ() + 0.5, SoundEvents.BLOCK_STONE_PRESSPLATE_CLICK_OFF, SoundCategory.BLOCKS, 0.3F, 0.7F);
|
||||
}
|
||||
|
||||
setActive(isActive);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -158,11 +159,11 @@ public class TileEntityDynamicTank extends TileEntityMultiblock<SynchronizedTank
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivate(EntityPlayer player)
|
||||
public boolean onActivate(EntityPlayer player, EnumHand hand, ItemStack stack)
|
||||
{
|
||||
if(!player.isSneaking() && structure != null)
|
||||
{
|
||||
if(!BlockBasic.manageInventory(player, this))
|
||||
if(!BlockBasic.manageInventory(player, this, hand, stack))
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
player.openGui(Mekanism.instance, 18, worldObj, getPos().getX(), getPos().getY(), getPos().getZ());
|
||||
|
||||
@@ -20,6 +20,7 @@ import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
@@ -61,7 +62,7 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivate(EntityPlayer player)
|
||||
public boolean onActivate(EntityPlayer player, EnumHand hand, ItemStack stack)
|
||||
{
|
||||
if(!player.isSneaking() && structure != null)
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ import mekanism.api.IConfigCardAccess.ISpecialConfigData;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.common.HashList;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismSounds;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.base.ILogisticalTransporter;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
@@ -38,6 +39,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
@@ -564,7 +566,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||
|
||||
if(active)
|
||||
{
|
||||
worldObj.playSoundEffect(getPos().getX(), getPos().getY(), getPos().getZ(), "mekanism:etc.Click", 0.3F, 1);
|
||||
worldObj.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), MekanismSounds.CLICK, SoundCategory.BLOCKS, 0.3F, 1);
|
||||
}
|
||||
|
||||
clientActive = active;
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -305,7 +306,7 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivate(EntityPlayer player)
|
||||
public boolean onActivate(EntityPlayer player, EnumHand hand, ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -7,15 +7,17 @@ import mekanism.api.Coord4D;
|
||||
import mekanism.common.multiblock.IMultiblock;
|
||||
import mekanism.common.multiblock.IStructuralMultiblock;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
public class TileEntityStructuralGlass extends TileEntity implements IStructuralMultiblock
|
||||
{
|
||||
public Coord4D master;
|
||||
|
||||
@Override
|
||||
public boolean onActivate(EntityPlayer player)
|
||||
public boolean onActivate(EntityPlayer player, EnumHand hand, ItemStack stack)
|
||||
{
|
||||
if(master != null)
|
||||
{
|
||||
@@ -23,7 +25,7 @@ public class TileEntityStructuralGlass extends TileEntity implements IStructural
|
||||
|
||||
if(masterTile instanceof IMultiblock)
|
||||
{
|
||||
return ((IMultiblock)masterTile).onActivate(player);
|
||||
return ((IMultiblock)masterTile).onActivate(player, hand, stack);
|
||||
}
|
||||
else {
|
||||
master = null;
|
||||
|
||||
@@ -158,27 +158,45 @@ public class VoiceConnection extends Thread
|
||||
{
|
||||
for(ItemStack itemStack : getPlayer().inventory.mainInventory)
|
||||
{
|
||||
if(itemStack != null)
|
||||
if(canListen(channel, itemStack))
|
||||
{
|
||||
if(itemStack.getItem() instanceof ItemWalkieTalkie)
|
||||
{
|
||||
if(((ItemWalkieTalkie)itemStack.getItem()).getOn(itemStack))
|
||||
{
|
||||
if(((ItemWalkieTalkie)itemStack.getItem()).getChannel(itemStack) == channel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for(ItemStack itemStack : getPlayer().inventory.offHandInventory)
|
||||
{
|
||||
if(canListen(channel, itemStack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canListen(int channel, ItemStack itemStack)
|
||||
{
|
||||
if(itemStack != null)
|
||||
{
|
||||
if(itemStack.getItem() instanceof ItemWalkieTalkie)
|
||||
{
|
||||
if(((ItemWalkieTalkie)itemStack.getItem()).getOn(itemStack))
|
||||
{
|
||||
if(((ItemWalkieTalkie)itemStack.getItem()).getChannel(itemStack) == channel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getCurrentChannel()
|
||||
{
|
||||
ItemStack itemStack = getPlayer().getCurrentEquippedItem();
|
||||
ItemStack itemStack = getPlayer().inventory.getCurrentItem();
|
||||
|
||||
if(itemStack != null)
|
||||
{
|
||||
|
||||
@@ -48,6 +48,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -83,6 +84,9 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
|
||||
|
||||
public Random machineRand = new Random();
|
||||
|
||||
private static final AxisAlignedBB SOLAR_BOUNDS = new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 0.7F, 1.0F);
|
||||
private static final AxisAlignedBB ROTOR_BOUNDS = new AxisAlignedBB(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F);
|
||||
|
||||
public BlockGenerator()
|
||||
{
|
||||
super(Material.IRON);
|
||||
@@ -174,14 +178,6 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, World world, BlockPos pos)
|
||||
{
|
||||
setBlockBoundsBasedOnState(world, pos);
|
||||
|
||||
return super.getCollisionBoundingBox(state, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock)
|
||||
@@ -401,7 +397,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing side, float playerX, float playerY, float playerZ)
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float playerX, float playerY, float playerZ)
|
||||
{
|
||||
if(world.isRemote)
|
||||
{
|
||||
@@ -411,9 +407,9 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
|
||||
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos);
|
||||
int metadata = state.getBlock().getMetaFromState(state);
|
||||
|
||||
if(entityplayer.getCurrentEquippedItem() != null)
|
||||
if(stack != null)
|
||||
{
|
||||
Item tool = entityplayer.getCurrentEquippedItem().getItem();
|
||||
Item tool = stack.getItem();
|
||||
|
||||
if(MekanismUtils.hasUsableWrench(entityplayer, pos))
|
||||
{
|
||||
@@ -421,7 +417,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
|
||||
{
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
dismantleBlock(world, pos, false);
|
||||
dismantleBlock(state, world, pos, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -446,7 +442,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
|
||||
|
||||
if(metadata == GeneratorType.TURBINE_CASING.meta || metadata == GeneratorType.TURBINE_VALVE.meta || metadata == GeneratorType.TURBINE_VENT.meta)
|
||||
{
|
||||
return ((IMultiblock)tileEntity).onActivate(entityplayer);
|
||||
return ((IMultiblock)tileEntity).onActivate(entityplayer, hand, stack);
|
||||
}
|
||||
|
||||
if(metadata == GeneratorType.TURBINE_ROTOR.meta)
|
||||
@@ -455,17 +451,17 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
|
||||
|
||||
if(!entityplayer.isSneaking())
|
||||
{
|
||||
if(entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().getItem() == GeneratorsItems.TurbineBlade)
|
||||
if(stack != null && stack.getItem() == GeneratorsItems.TurbineBlade)
|
||||
{
|
||||
if(!world.isRemote && rod.editBlade(true))
|
||||
{
|
||||
if(!entityplayer.capabilities.isCreativeMode)
|
||||
{
|
||||
entityplayer.getCurrentEquippedItem().stackSize--;
|
||||
stack.stackSize--;
|
||||
|
||||
if(entityplayer.getCurrentEquippedItem().stackSize == 0)
|
||||
if(stack.stackSize == 0)
|
||||
{
|
||||
entityplayer.setCurrentItemOrArmor(0, null);
|
||||
entityplayer.setHeldItem(hand, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -476,26 +472,26 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
|
||||
else {
|
||||
if(!world.isRemote)
|
||||
{
|
||||
if(entityplayer.getCurrentEquippedItem() == null)
|
||||
if(stack == null)
|
||||
{
|
||||
if(rod.editBlade(false))
|
||||
{
|
||||
if(!entityplayer.capabilities.isCreativeMode)
|
||||
{
|
||||
entityplayer.setCurrentItemOrArmor(0, new ItemStack(GeneratorsItems.TurbineBlade));
|
||||
entityplayer.setHeldItem(hand, new ItemStack(GeneratorsItems.TurbineBlade));
|
||||
entityplayer.inventory.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(entityplayer.getCurrentEquippedItem().getItem() == GeneratorsItems.TurbineBlade)
|
||||
else if(stack.getItem() == GeneratorsItems.TurbineBlade)
|
||||
{
|
||||
if(entityplayer.getCurrentEquippedItem().stackSize < entityplayer.getCurrentEquippedItem().getMaxStackSize())
|
||||
if(stack.stackSize < stack.getMaxStackSize())
|
||||
{
|
||||
if(rod.editBlade(false))
|
||||
{
|
||||
if(!entityplayer.capabilities.isCreativeMode)
|
||||
{
|
||||
entityplayer.getCurrentEquippedItem().stackSize++;
|
||||
stack.stackSize++;
|
||||
entityplayer.inventory.markDirty();
|
||||
}
|
||||
}
|
||||
@@ -579,23 +575,20 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
GeneratorType type = GeneratorType.get(getGeneratorBlock(), state.getBlock().getMetaFromState(state));
|
||||
GeneratorType type = GeneratorType.get(state);
|
||||
|
||||
if(type == GeneratorType.SOLAR_GENERATOR)
|
||||
switch(type)
|
||||
{
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.7F, 1.0F);
|
||||
}
|
||||
else if(type == GeneratorType.TURBINE_ROTOR)
|
||||
{
|
||||
setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F);
|
||||
}
|
||||
else {
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
case SOLAR_GENERATOR:
|
||||
return SOLAR_BOUNDS;
|
||||
case TURBINE_ROTOR:
|
||||
return ROTOR_BOUNDS;
|
||||
default:
|
||||
return super.getBoundingBox(state, world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -159,7 +160,7 @@ public abstract class BlockReactor extends BlockContainer implements ICTMBlock
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing facing, float playerX, float playerY, float playerZ)
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing facing, float playerX, float playerY, float playerZ)
|
||||
{
|
||||
if(world.isRemote)
|
||||
{
|
||||
@@ -169,9 +170,9 @@ public abstract class BlockReactor extends BlockContainer implements ICTMBlock
|
||||
TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getTileEntity(pos);
|
||||
int metadata = state.getBlock().getMetaFromState(state);
|
||||
|
||||
if(entityplayer.getCurrentEquippedItem() != null)
|
||||
if(stack != null)
|
||||
{
|
||||
if(MekanismUtils.isBCWrench(entityplayer.getCurrentEquippedItem().getItem()) && !entityplayer.getCurrentEquippedItem().getUnlocalizedName().contains("omniwrench"))
|
||||
if(MekanismUtils.isBCWrench(stack.getItem()) && !stack.getUnlocalizedName().contains("omniwrench"))
|
||||
{
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
@@ -179,7 +180,7 @@ public abstract class BlockReactor extends BlockContainer implements ICTMBlock
|
||||
return true;
|
||||
}
|
||||
|
||||
((IToolWrench)entityplayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityplayer, pos);
|
||||
((IToolWrench)stack.getItem()).wrenchUsed(entityplayer, pos);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import mekanism.generators.common.content.turbine.SynchronizedTurbineData;
|
||||
import mekanism.generators.common.content.turbine.TurbineCache;
|
||||
import mekanism.generators.common.content.turbine.TurbineUpdateProtocol;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -115,7 +117,7 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock<SynchronizedTu
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivate(EntityPlayer player)
|
||||
public boolean onActivate(EntityPlayer player, EnumHand hand, ItemStack stack)
|
||||
{
|
||||
if(!player.isSneaking() && structure != null)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user