Clean up formatting of Forge Test mods and disable noisy ones (#3908)

This commit is contained in:
mezz authored and LexManos committed 2017-05-29 02:10:40 -07:00
1 parent 4ea73399de
commit e6dcfde214
75 files changed
+1378 -820

No files matched your search

@@ -1,8 +1,7 @@
package net.minecraftforge.debug;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Ints;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
@@ -45,10 +44,9 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Ints;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
@Mod(modid = ModelBakeEventDebug.MODID, name = "ForgeDebugModelBakeEvent", version = ModelBakeEventDebug.VERSION, acceptableRemoteVersions = "*")
public class ModelBakeEventDebug
@@ -64,7 +62,7 @@ public class ModelBakeEventDebug
static
{
for(EnumFacing f : EnumFacing.values())
for (EnumFacing f : EnumFacing.values())
{
properties[f.ordinal()] = Properties.toUnlisted(PropertyInteger.create(f.getName(), 0, (1 << (cubeSize * cubeSize)) - 1));
}
@@ -74,7 +72,10 @@ public class ModelBakeEventDebug
public static CommonProxy proxy;
@EventHandler
public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); }
public void preInit(FMLPreInitializationEvent event)
{
proxy.preInit(event);
}
public static class CommonProxy
{
@@ -86,7 +87,9 @@ public class ModelBakeEventDebug
}
}
public static class ServerProxy extends CommonProxy {}
public static class ServerProxy extends CommonProxy
{
}
public static class ClientProxy extends CommonProxy
{
@@ -99,7 +102,8 @@ public class ModelBakeEventDebug
super.preInit(event);
Item item = Item.getItemFromBlock(CustomModelBlock.instance);
ModelLoader.setCustomModelResourceLocation(item, 0, itemLocation);
ModelLoader.setCustomStateMapper(CustomModelBlock.instance, new StateMapperBase(){
ModelLoader.setCustomStateMapper(CustomModelBlock.instance, new StateMapperBase()
{
protected ModelResourceLocation getModelResourceLocation(IBlockState p_178132_1_)
{
return blockLocation;
@@ -113,7 +117,9 @@ public class ModelBakeEventDebug
{
public static final BakeEventHandler instance = new BakeEventHandler();
private BakeEventHandler() {};
private BakeEventHandler()
{
}
@SubscribeEvent
public void onModelBakeEvent(ModelBakeEvent event)
@@ -140,16 +146,28 @@ public class ModelBakeEventDebug
}
@Override
public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; }
public EnumBlockRenderType getRenderType(IBlockState state)
{
return EnumBlockRenderType.MODEL;
}
@Override
public boolean isOpaqueCube(IBlockState state) { return false; }
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
public boolean isFullCube(IBlockState state) { return false; }
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean causesSuffocation(IBlockState state) { return false; }
public boolean causesSuffocation(IBlockState state)
{
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
@@ -161,14 +179,17 @@ public class ModelBakeEventDebug
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
TileEntity te = world.getTileEntity(pos);
if(te instanceof CustomTileEntity)
if (te instanceof CustomTileEntity)
{
CustomTileEntity cte = (CustomTileEntity) te;
Vec3d vec = revRotate(new Vec3d(hitX - .5, hitY - .5, hitZ - .5), side).addVector(.5, .5, .5);
IUnlistedProperty<Integer> property = properties[side.ordinal()];
Integer value = cte.getState().getValue(property);
if(value == null) value = 0;
value ^= (1 << ( cubeSize * ((int)(vec.xCoord * (cubeSize - .0001))) + ((int)(vec.zCoord * (cubeSize - .0001))) ));
if (value == null)
{
value = 0;
}
value ^= (1 << (cubeSize * ((int) (vec.xCoord * (cubeSize - .0001))) + ((int) (vec.zCoord * (cubeSize - .0001)))));
cte.setState(cte.getState().withProperty(property, value));
world.markBlockRangeForRenderUpdate(pos, pos);
}
@@ -179,7 +200,7 @@ public class ModelBakeEventDebug
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
{
TileEntity te = world.getTileEntity(pos);
if(te instanceof CustomTileEntity)
if (te instanceof CustomTileEntity)
{
CustomTileEntity cte = (CustomTileEntity) te;
return cte.getState();
@@ -197,13 +218,16 @@ public class ModelBakeEventDebug
public static class CustomTileEntity extends TileEntity
{
private IExtendedBlockState state;
public CustomTileEntity() {}
public CustomTileEntity()
{
}
public IExtendedBlockState getState()
{
if(state == null)
if (state == null)
{
state = (IExtendedBlockState)getBlockType().getDefaultState();
state = (IExtendedBlockState) getBlockType().getDefaultState();
}
return state;
}
@@ -228,14 +252,14 @@ public class ModelBakeEventDebug
// TODO update to builder
private int[] vertexToInts(float x, float y, float z, int color, TextureAtlasSprite texture, float u, float v)
{
return new int[] {
Float.floatToRawIntBits(x),
Float.floatToRawIntBits(y),
Float.floatToRawIntBits(z),
color,
Float.floatToRawIntBits(texture.getInterpolatedU(u)),
Float.floatToRawIntBits(texture.getInterpolatedV(v)),
0
return new int[]{
Float.floatToRawIntBits(x),
Float.floatToRawIntBits(y),
Float.floatToRawIntBits(z),
color,
Float.floatToRawIntBits(texture.getInterpolatedU(u)),
Float.floatToRawIntBits(texture.getInterpolatedV(v)),
0
};
}
@@ -246,33 +270,36 @@ public class ModelBakeEventDebug
Vec3d v3 = rotate(new Vec3d(x2 - .5, y - .5, z2 - .5), side).addVector(.5, .5, .5);
Vec3d v4 = rotate(new Vec3d(x2 - .5, y - .5, z1 - .5), side).addVector(.5, .5, .5);
return new BakedQuad(Ints.concat(
vertexToInts((float)v1.xCoord, (float)v1.yCoord, (float)v1.zCoord, -1, texture, 0, 0),
vertexToInts((float)v2.xCoord, (float)v2.yCoord, (float)v2.zCoord, -1, texture, 0, 16),
vertexToInts((float)v3.xCoord, (float)v3.yCoord, (float)v3.zCoord, -1, texture, 16, 16),
vertexToInts((float)v4.xCoord, (float)v4.yCoord, (float)v4.zCoord, -1, texture, 16, 0)
vertexToInts((float) v1.xCoord, (float) v1.yCoord, (float) v1.zCoord, -1, texture, 0, 0),
vertexToInts((float) v2.xCoord, (float) v2.yCoord, (float) v2.zCoord, -1, texture, 0, 16),
vertexToInts((float) v3.xCoord, (float) v3.yCoord, (float) v3.zCoord, -1, texture, 16, 16),
vertexToInts((float) v4.xCoord, (float) v4.yCoord, (float) v4.zCoord, -1, texture, 16, 0)
), -1, side, texture, true, DefaultVertexFormats.BLOCK);
}
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
{
if(side != null) return ImmutableList.of();
IExtendedBlockState exState = (IExtendedBlockState)state;
if (side != null)
{
return ImmutableList.of();
}
IExtendedBlockState exState = (IExtendedBlockState) state;
int len = cubeSize * 5 + 1;
List<BakedQuad> ret = new ArrayList<BakedQuad>();
for(EnumFacing f : EnumFacing.values())
for (EnumFacing f : EnumFacing.values())
{
ret.add(createSidedBakedQuad(0, 1, 0, 1, 1, base, f));
if(state != null)
if (state != null)
{
for(int i = 0; i < cubeSize; i++)
for (int i = 0; i < cubeSize; i++)
{
for(int j = 0; j < cubeSize; j++)
for (int j = 0; j < cubeSize; j++)
{
Integer value = exState.getValue(properties[f.ordinal()]);
if(value != null && (value & (1 << (i * cubeSize + j))) != 0)
if (value != null && (value & (1 << (i * cubeSize + j))) != 0)
{
ret.add(createSidedBakedQuad((float)(1 + i * 5) / len, (float)(5 + i * 5) / len, (float)(1 + j * 5) / len, (float)(5 + j * 5) / len, 1.0001f, overlay, f));
ret.add(createSidedBakedQuad((float) (1 + i * 5) / len, (float) (5 + i * 5) / len, (float) (1 + j * 5) / len, (float) (5 + j * 5) / len, 1.0001f, overlay, f));
}
}
}
@@ -282,48 +309,78 @@ public class ModelBakeEventDebug
}
@Override
public boolean isGui3d() { return true; }
public boolean isGui3d()
{
return true;
}
@Override
public boolean isAmbientOcclusion() { return true; }
public boolean isAmbientOcclusion()
{
return true;
}
@Override
public boolean isBuiltInRenderer() { return false; }
public boolean isBuiltInRenderer()
{
return false;
}
@Override
public TextureAtlasSprite getParticleTexture() { return this.base; }
public TextureAtlasSprite getParticleTexture()
{
return this.base;
}
@Override
public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; }
public ItemCameraTransforms getItemCameraTransforms()
{
return ItemCameraTransforms.DEFAULT;
}
@Override
public ItemOverrideList getOverrides() { return ItemOverrideList.NONE; }
public ItemOverrideList getOverrides()
{
return ItemOverrideList.NONE;
}
}
private static Vec3d rotate(Vec3d vec, EnumFacing side)
{
switch(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);
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);
}
throw new IllegalArgumentException("Unknown Side " + side);
}
private static Vec3d revRotate(Vec3d vec, EnumFacing side)
{
switch(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);
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);
}
throw new IllegalArgumentException("Unknown Side " + side);
}