Skip to content

Commit

Permalink
Merge pull request #1120 from malte0811/transformerFixes
Browse files Browse the repository at this point in the history
Mostly transformer fixes
  • Loading branch information
BluSunrize committed May 11, 2016
2 parents 58aa5c9 + 2e53cfa commit 2a548d6
Show file tree
Hide file tree
Showing 25 changed files with 91 additions and 25 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ version = "${mainVersion}-${buildNumber}"
group= "blusunrize"
archivesBaseName = "ImmersiveEngineering"

sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8

minecraft {
version = "1.8.9-11.15.1.1855"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package blusunrize.immersiveengineering.api.energy.wires;

import java.util.Set;

import com.google.common.collect.ImmutableSet;

import blusunrize.immersiveengineering.api.ApiUtils;
import blusunrize.immersiveengineering.api.TargetingInfo;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
import net.minecraft.util.BlockPos;
Expand Down Expand Up @@ -77,4 +82,11 @@ public interface IImmersiveConnectable
* @return Where the cable should attach
*/
public Vec3 getConnectionOffset(Connection con);
/**
* returns a set of Blocks to be ignored when raytracing
*/
public default Set<BlockPos> getIgnored(IImmersiveConnectable other)
{
return ImmutableSet.of(ApiUtils.toBlockPos(this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket)
try{
if(nbt.hasKey("limitType"))
limitType = ApiUtils.getWireTypeFromNBT(nbt, "limitType");
else
limitType = null;

// int[] prevPos = nbt.getIntArray("prevPos");
// if(prevPos!=null && prevPos.length>3 && FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import blusunrize.immersiveengineering.api.shader.IShaderEquipableItem;
import blusunrize.immersiveengineering.api.shader.IShaderItem;
import blusunrize.immersiveengineering.api.shader.ShaderCase;
import blusunrize.immersiveengineering.client.models.smart.ConnModelReal.ExtBlockstateAdapter;
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -293,8 +294,8 @@ public OBJBakedModel handleBlockState(IBlockState state)
if(state instanceof IExtendedBlockState)
{
IExtendedBlockState exState = (IExtendedBlockState) state;
int hash = getExtendedStateHash(exState);
if(!modelCache.containsKey(hash))
ExtBlockstateAdapter adapter = new ExtBlockstateAdapter(exState);
if(!modelCache.containsKey(adapter))
{
IESmartObjModel model = null;
if(exState.getUnlistedNames().contains(OBJProperty.instance))
Expand All @@ -312,9 +313,9 @@ public OBJBakedModel handleBlockState(IBlockState state)
if(model==null)
model = new IESmartObjModel(baseModel, getModel(), this.getState(), getFormat(), getTextures(), transformationMap);
model.tempState = state;
modelCache.put(hash, model);
modelCache.put(adapter, model);
}
return modelCache.get(hash);
return modelCache.get(adapter);
}
return this;
}
Expand All @@ -323,7 +324,7 @@ static int getExtendedStateHash(IExtendedBlockState state)
return state.hashCode()*31 + state.getUnlistedProperties().hashCode();
}

static HashMap<Integer, IESmartObjModel> modelCache = new HashMap();
static HashMap<ExtBlockstateAdapter, IESmartObjModel> modelCache = new HashMap<>();
// private final LoadingCache<Integer, IESmartObjModel> ieobjcache = CacheBuilder.newBuilder().maximumSize(20).build(new CacheLoader<Integer, IESmartObjModel>()
// {
// public IESmartObjModel load(IModelState state) throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public ItemCameraTransforms getItemCameraTransforms()

}

private class ExtBlockstateAdapter
public static class ExtBlockstateAdapter
{
final IExtendedBlockState state;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,14 @@ protected IBlockState getInitDefaultState()
IBlockState state = this.blockState.getBaseState().withProperty(this.property, enumValues[0]);
for(int i=0; i<this.additionalProperties.length; i++)
if(this.additionalProperties[i]!=null && !this.additionalProperties[i].getAllowedValues().isEmpty())
state = state.withProperty(this.additionalProperties[i], this.additionalProperties[i].getAllowedValues().toArray()[0]);
state = applyProperty(state, additionalProperties[i], additionalProperties[i].getAllowedValues().iterator().next());
return state;
}

protected <V extends Comparable<V>> IBlockState applyProperty(IBlockState in, IProperty<V> prop, Object val)
{
return in.withProperty(prop, (V)val);
}

public void onIEBlockPlacedBy(World world, BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase placer, ItemStack stack)
{
Expand Down Expand Up @@ -291,7 +296,7 @@ public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPo
{
for(int i=0; i<this.additionalProperties.length; i++)
if(this.additionalProperties[i]!=null && !this.additionalProperties[i].getAllowedValues().isEmpty())
state = state.withProperty(this.additionalProperties[i], this.additionalProperties[i].getAllowedValues().toArray()[0]);
state = applyProperty(state, this.additionalProperties[i], this.additionalProperties[i].getAllowedValues().toArray()[0]);
return state;
}
@Override
Expand All @@ -300,7 +305,7 @@ public IBlockState getStateFromMeta(int meta)
IBlockState state = this.getDefaultState().withProperty(this.property, fromMeta(meta));
for(int i=0; i<this.additionalProperties.length; i++)
if(this.additionalProperties[i]!=null && !this.additionalProperties[i].getAllowedValues().isEmpty())
state = state.withProperty(this.additionalProperties[i], this.additionalProperties[i].getAllowedValues().toArray()[0]);
state = applyProperty(state, this.additionalProperties[i], this.additionalProperties[i].getAllowedValues().toArray()[0]);
return state;
// return this.getDefaultState().withProperty(this.property, fromMeta(meta));
}
Expand Down Expand Up @@ -349,6 +354,16 @@ else if(this.blockMaterial==Material.wood||this.blockMaterial==Material.cactus)
this.stepSound = Block.soundTypeWood;
}

public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam)
{
if (worldIn.isRemote&&eventID==255)
{
worldIn.markBlockForUpdate(pos);
return true;
}
return super.onBlockEventReceived(worldIn, pos, state, eventID, eventParam);
}

public boolean allowHammerHarvest(IBlockState blockState)
{
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ else if(tile instanceof IHasDummyBlocks)

return state;
}
protected IBlockState applyProperty(IBlockState state, IProperty property, Object value)
{
if(state.getProperties().containsKey(property))
state = state.withProperty(property, value);
return state;
}

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;

import blusunrize.immersiveengineering.api.ApiUtils;
Expand Down Expand Up @@ -93,6 +95,8 @@ public void readCustomNBT(NBTTagCompound nbt, boolean descPacket)
facing = EnumFacing.getFront(nbt.getInteger("facing"));
if(nbt.hasKey("secondCable"))
secondCable = ApiUtils.getWireTypeFromNBT(nbt, "secondCable");
else
secondCable = null;
dummy = nbt.getInteger("dummy");
postAttached = nbt.getInteger("postAttached");
}
Expand Down Expand Up @@ -377,4 +381,8 @@ public boolean isOverrideBox(AxisAlignedBB box, EntityPlayer player, MovingObjec
return true;
return false;
}
@Override
public Set<BlockPos> getIgnored(IImmersiveConnectable other) {
return ImmutableSet.of(pos.up(), pos.up(2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit
tile.pos = h*25 + l*5 + (w+2);
tile.offset = new int[]{(side==EnumFacing.WEST?-l+2: side==EnumFacing.EAST?l-2: side==EnumFacing.NORTH?ww: -ww),h-1,(side==EnumFacing.NORTH?-l+2: side==EnumFacing.SOUTH?l-2: side==EnumFacing.EAST?ww : -ww)};
tile.mirrored = mirrored;
tile.markDirty();
world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
}
}
player.triggerAchievement(IEAchievements.mbArcFurnace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit
int xx = f==EnumFacing.EAST?l: f==EnumFacing.WEST?-l: f==EnumFacing.NORTH?-w:w;
int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w:-w;

world.setBlockState(pos.add(xx, h, zz), IEContent.blockStoneDevice.getStateFromMeta(1));
TileEntity curr = world.getTileEntity(pos.add(xx, h, zz));
BlockPos pos2 = pos.add(xx, h, zz);
world.setBlockState(pos2, IEContent.blockStoneDevice.getStateFromMeta(1));
TileEntity curr = world.getTileEntity(pos2);
if(curr instanceof TileEntityBlastFurnace)
{
TileEntityBlastFurnace currBlast = (TileEntityBlastFurnace) curr;
Expand All @@ -99,6 +100,7 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit
currBlast.facing=f.getOpposite();
currBlast.formed=true;
currBlast.markDirty();
world.addBlockEvent(pos2, IEContent.blockStoneDevice, 255, 0);
}
}
player.triggerAchievement(IEAchievements.blastfurnace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit
int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w:-w;

world.setBlockState(pos.add(xx, h, zz), IEContent.blockStoneDevice.getStateFromMeta(2));
TileEntity curr = world.getTileEntity(pos.add(xx, h, zz));
BlockPos pos2 = pos.add(xx, h, zz);
TileEntity curr = world.getTileEntity(pos2);
if(curr instanceof TileEntityBlastFurnace)
{
TileEntityBlastFurnace currBlast = (TileEntityBlastFurnace) curr;
Expand All @@ -126,6 +127,7 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit
currBlast.facing=f.getOpposite();
currBlast.formed=true;
currBlast.markDirty();
world.addBlockEvent(pos2, IEContent.blockStoneDevice, 255, 0);
}
}
player.triggerAchievement(IEAchievements.mbImprovedBlastFurnace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit
tile.pos = (w+3) + (h+3)*7;

tile.offset = new int[]{(side==EnumFacing.NORTH?w: side==EnumFacing.SOUTH?-w: 0),h,(side==EnumFacing.WEST?w: side==EnumFacing.EAST?-w: 0)};
tile.markDirty();
world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit
int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w:-w;

world.setBlockState(pos.add(xx, h, zz), IEContent.blockStoneDevice.getStateFromMeta(0));
TileEntity curr = world.getTileEntity(pos.add(xx, h, zz));
BlockPos pos2 = pos.add(xx, h, zz);
TileEntity curr = world.getTileEntity(pos2);
if(curr instanceof TileEntityCokeOven)
{
TileEntityCokeOven currBlast = (TileEntityCokeOven) curr;
Expand All @@ -99,6 +100,7 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit
currBlast.facing=f.getOpposite();
currBlast.formed=true;
currBlast.markDirty();
world.addBlockEvent(pos2, IEContent.blockStoneDevice, 255, 0);
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit
tile.pos = (h+1)*15 + l*5 + (w+2);
tile.offset = new int[]{(side==EnumFacing.WEST?-l+1: side==EnumFacing.EAST?l-1: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?-l+1: side==EnumFacing.SOUTH?l-1: side==EnumFacing.EAST?ww : -ww)};
tile.mirrored = mirrored;
tile.markDirty();
world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
}
}
player.triggerAchievement(IEAchievements.mbCrusher);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit
tile.pos = (h+1)*15 + l*3 + (w+1);
tile.offset = new int[]{(side==EnumFacing.WEST?-l+2: side==EnumFacing.EAST?l-2: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?-l+2: side==EnumFacing.SOUTH?l-2: side==EnumFacing.EAST?ww : -ww)};
tile.mirrored=mirror;
tile.markDirty();
world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
}
}
player.triggerAchievement(IEAchievements.mbDieselGen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit
tile.pos = (h+1)*18 + l*3 + (w+1);
tile.offset = new int[]{(side==EnumFacing.WEST?-l: side==EnumFacing.EAST?l: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?-l: side==EnumFacing.SOUTH?l: side==EnumFacing.EAST?ww : -ww)};
tile.mirrored=mirror;
tile.markDirty();
world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
}
}
player.triggerAchievement(IEAchievements.mbExcavator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit
tile.pos = (h+1)*9 + (l+1)*3 + (w+1);
tile.offset = new int[]{(side==EnumFacing.WEST?-l: side==EnumFacing.EAST?l: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?-l: side==EnumFacing.SOUTH?l: side==EnumFacing.EAST?ww : -ww)};
tile.mirrored=mirror;
tile.markDirty();
world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ else if(h==0)
tile.formed=true;
tile.pos = (h+1)*3 + (l+1);
tile.offset = new int[]{(dir==EnumFacing.WEST?-l: dir==EnumFacing.EAST?l: 0),h,(dir==EnumFacing.NORTH?-l: dir==EnumFacing.SOUTH?l: 0)};
tile.markDirty();
world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
}
}
player.triggerAchievement(IEAchievements.mbMetalPress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ else if(w==0)
tile.pos = (h+1)*15 + l*5 + (w+2);
tile.offset = new int[]{(side==EnumFacing.WEST?-l: side==EnumFacing.EAST?l: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?-l: side==EnumFacing.SOUTH?l: side==EnumFacing.EAST?ww : -ww)};
tile.mirrored=mirror;
tile.markDirty();
world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ else if(!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w:-w;

world.setBlockState(pos.add(xx, h, zz), IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.TANK.getMeta()));
TileEntity curr = world.getTileEntity(pos.add(xx, h, zz));
BlockPos pos2 = pos.add(xx, h, zz);
TileEntity curr = world.getTileEntity(pos2);
if(curr instanceof TileEntitySheetmetalTank)
{
TileEntitySheetmetalTank currTank = (TileEntitySheetmetalTank) curr;
Expand All @@ -150,6 +151,7 @@ else if(!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
currTank.formed=true;
currTank.offset=new int[]{xx,h,zz};
currTank.markDirty();
world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ else if(!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
int zz = f==EnumFacing.NORTH?l: f==EnumFacing.SOUTH?-l: f==EnumFacing.EAST?w:-w;

world.setBlockState(pos.add(xx, h, zz), IEContent.blockMetalMultiblock.getStateFromMeta(BlockTypes_MetalMultiblock.SILO.getMeta()));
TileEntity curr = world.getTileEntity(pos.add(xx, h, zz));
BlockPos pos2 = pos.add(xx, h, zz);
TileEntity curr = world.getTileEntity(pos2);
if(curr instanceof TileEntitySilo)
{
TileEntitySilo currTank = (TileEntitySilo) curr;
Expand All @@ -151,6 +152,7 @@ else if(!Utils.isOreBlockAt(world, pos.add(xx, h, zz), "blockSheetmetalIron"))
currTank.formed=true;
currTank.offset=new int[]{xx,h,zz};
currTank.markDirty();
world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
}
}
player.triggerAchievement(IEAchievements.mbSilo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ public boolean createStructure(World world, BlockPos pos, EnumFacing side, Entit
tile.pos = (h+1)*9 + (l+1)*3 + (w+1);
tile.offset = new int[]{(side==EnumFacing.WEST?-l: side==EnumFacing.EAST?l: side==EnumFacing.NORTH?ww: -ww),h,(side==EnumFacing.NORTH?-l: side==EnumFacing.SOUTH?l: side==EnumFacing.EAST?ww : -ww)};
tile.mirrored=mirror;
tile.markDirty();
world.addBlockEvent(pos2, IEContent.blockMetalMultiblock, 255, 0);
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float
{
worldObj.setBlockState(pos.add(0,i,0), state);
((TileEntityWoodenPost)worldObj.getTileEntity(pos.add(0,i,0))).dummy = (byte)i;
worldObj.addBlockEvent(pos.add(0, i, 0), getBlockType(), 255, 0);
}
}
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package blusunrize.immersiveengineering.common.items;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

Expand Down Expand Up @@ -126,7 +127,10 @@ else if(!(tileEntityLinkingPos instanceof IImmersiveConnectable))
{
Vec3 rtOff0 = nodeHere.getRaytraceOffset(nodeLink).addVector(masterPos.getX(), masterPos.getY(), masterPos.getZ());
Vec3 rtOff1 = nodeLink.getRaytraceOffset(nodeHere).addVector(linkPos.getX(), linkPos.getY(), linkPos.getZ());
boolean canSee = Utils.canBlocksSeeOther(world, masterPos, linkPos, rtOff0,rtOff1);
Set<BlockPos> ignore = new HashSet<>();
ignore.addAll(nodeHere.getIgnored(nodeLink));
ignore.addAll(nodeLink.getIgnored(nodeHere));
boolean canSee = Utils.rayTraceForFirst(rtOff0, rtOff1, world, ignore)==null;
if(canSee)
{
TargetingInfo targetLink = TargetingInfo.readFromNBT(stack.getTagCompound());
Expand Down
Loading

0 comments on commit 2a548d6

Please sign in to comment.