mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-18 11:19:20 +00:00
Code cleanup
This commit is contained in:
1 parent
ddea705e83
commit
9fa56c7375
23 files changed
+276
-311
No files matched your search
@@ -16,7 +16,7 @@ import slimeknights.mantle.common.CommonProxy;
|
||||
*
|
||||
* @author Sunstrike <[email protected]>
|
||||
*/
|
||||
@Mod(modid = Mantle.modId, name = Mantle.modName, version = Mantle.modVersion, dependencies = "required-after:Forge@[11.15,)", acceptedMinecraftVersions="[1.8.8,1.8.9]")
|
||||
@Mod(modid = Mantle.modId, name = Mantle.modName, version = Mantle.modVersion, dependencies = "required-after:Forge@[11.15,)", acceptedMinecraftVersions = "[1.8.8,1.8.9]")
|
||||
public class Mantle {
|
||||
|
||||
public static final String modId = "mantle";
|
||||
|
||||
@@ -10,9 +10,9 @@ import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import slimeknights.mantle.tileentity.TileInventory;
|
||||
@@ -86,8 +86,7 @@ public abstract class BlockInventory extends BlockContainer {
|
||||
// BlockContainer sets this to invisible
|
||||
// we need model for standard forge rendering
|
||||
@Override
|
||||
public EnumBlockRenderType getRenderType(IBlockState state)
|
||||
{
|
||||
public EnumBlockRenderType getRenderType(IBlockState state) {
|
||||
return EnumBlockRenderType.MODEL;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
|
||||
public class EnumBlock<E extends Enum<E> & EnumBlock.IEnumMeta & IStringSerializable> extends Block {
|
||||
|
||||
public final PropertyEnum<E> prop;
|
||||
private final E[] values;
|
||||
|
||||
@@ -28,7 +29,7 @@ public class EnumBlock<E extends Enum<E> & EnumBlock.IEnumMeta & IStringSerializ
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Material preInit(Material material, PropertyEnum<?> property) {
|
||||
tmp=property;
|
||||
tmp = property;
|
||||
return material;
|
||||
}
|
||||
|
||||
@@ -72,6 +73,7 @@ public class EnumBlock<E extends Enum<E> & EnumBlock.IEnumMeta & IStringSerializ
|
||||
}
|
||||
|
||||
public interface IEnumMeta {
|
||||
|
||||
int getMeta();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,8 @@ public class ModelHelper {
|
||||
data[i * 7 + 3] = c;
|
||||
}
|
||||
|
||||
return new BakedQuad(data, quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat());
|
||||
return new BakedQuad(data, quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad
|
||||
.shouldApplyDiffuseLighting(), quad.getFormat());
|
||||
}
|
||||
|
||||
public static Map<String, String> loadTexturesFromJson(ResourceLocation location) throws IOException {
|
||||
@@ -100,8 +101,7 @@ public class ModelHelper {
|
||||
return new ResourceLocation(location.getResourceDomain(), "models/" + location.getResourcePath() + ".json");
|
||||
}
|
||||
|
||||
private static TRSRTransformation get(float tx, float ty, float tz, float ax, float ay, float az, float s)
|
||||
{
|
||||
private static TRSRTransformation get(float tx, float ty, float tz, float ax, float ay, float az, float s) {
|
||||
return TRSRTransformation.blockCenterToCorner(new TRSRTransformation(
|
||||
new Vector3f(tx / 16, ty / 16, tz / 16),
|
||||
TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)),
|
||||
@@ -128,7 +128,7 @@ public class ModelHelper {
|
||||
}
|
||||
{
|
||||
BLOCK_THIRD_PERSON_RIGHT = get(0, 2.5f, 0, 75, 45, 0, 0.375f);
|
||||
BLOCK_THIRD_PERSON_LEFT = get(0, 0, 0, 0, 255, 0, 0.4f);
|
||||
BLOCK_THIRD_PERSON_LEFT = get(0, 0, 0, 0, 255, 0, 0.4f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,8 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
// a sub-gui. Mostly the same as a separate GuiContainer, but doesn't do the calls that affect the game as if this were the only gui
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -58,7 +58,7 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
|
||||
|
||||
public List<Rectangle> getModuleAreas() {
|
||||
List<Rectangle> areas = new ArrayList<Rectangle>(modules.size());
|
||||
for (GuiModule module : modules) {
|
||||
for(GuiModule module : modules) {
|
||||
areas.add(module.getArea());
|
||||
}
|
||||
return areas;
|
||||
@@ -98,7 +98,7 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
drawContainerName();
|
||||
drawPlayerInventoryName();
|
||||
|
||||
|
||||
for(GuiModule module : modules) {
|
||||
// set correct state for the module
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package slimeknights.mantle.client.model;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
@@ -21,7 +19,6 @@ import net.minecraftforge.client.model.TRSRTransformation;
|
||||
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
|
||||
import net.minecraftforge.client.model.pipeline.VertexTransformer;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.vecmath.Matrix3f;
|
||||
@@ -161,7 +158,7 @@ public class TRSRBakedModel implements IBakedModel {
|
||||
}
|
||||
|
||||
public UnpackedBakedQuad build() {
|
||||
return ((UnpackedBakedQuad.Builder)parent).build();
|
||||
return ((UnpackedBakedQuad.Builder) parent).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemColored;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
@@ -32,7 +32,9 @@ public class ItemBlockMeta extends ItemColored {
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
if(mappingProperty == null) return super.getUnlocalizedName(stack);
|
||||
if(mappingProperty == null) {
|
||||
return super.getUnlocalizedName(stack);
|
||||
}
|
||||
|
||||
IBlockState state = block.getStateFromMeta(stack.getMetadata());
|
||||
String name = state.getValue(mappingProperty).toString().toLowerCase(Locale.US);
|
||||
@@ -40,7 +42,7 @@ public class ItemBlockMeta extends ItemColored {
|
||||
}
|
||||
|
||||
public static void setMappingProperty(Block block, IProperty<?> property) {
|
||||
((ItemBlockMeta)Item.getItemFromBlock(block)).mappingProperty = property;
|
||||
((ItemBlockMeta) Item.getItemFromBlock(block)).mappingProperty = property;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,11 +64,12 @@ public class ItemBlockMeta extends ItemColored {
|
||||
final ResourceLocation loc = GameData.getBlockRegistry().getNameForObject(block);
|
||||
|
||||
|
||||
for(Comparable o : (Collection<Comparable>)mappingProperty.getAllowedValues()) {
|
||||
for(Comparable o : (Collection<Comparable>) mappingProperty.getAllowedValues()) {
|
||||
int meta = block.getMetaFromState(block.getDefaultState().withProperty(mappingProperty, o));
|
||||
String name = mappingProperty.getName(o);
|
||||
|
||||
ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(loc, mappingProperty.getName() + "=" + name));
|
||||
ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(loc, mappingProperty
|
||||
.getName() + "=" + name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,11 +37,12 @@ public class ItemEdible extends ItemFood {
|
||||
|
||||
/**
|
||||
* Add a new food type!
|
||||
* @param meta Metadata to use, has to be free
|
||||
* @param food How much food it restores on eating
|
||||
* @param saturation Saturation multiplier on the food
|
||||
* @param name Unlocalized postfix
|
||||
* @param effects PotionEffects that will be applied on eating. The PotionEffect passed will be directly applied
|
||||
*
|
||||
* @param meta Metadata to use, has to be free
|
||||
* @param food How much food it restores on eating
|
||||
* @param saturation Saturation multiplier on the food
|
||||
* @param name Unlocalized postfix
|
||||
* @param effects PotionEffects that will be applied on eating. The PotionEffect passed will be directly applied
|
||||
* @return Itemstack containing the registered item
|
||||
*/
|
||||
public ItemStack addFood(int meta, int food, float saturation, String name, PotionEffect... effects) {
|
||||
@@ -67,10 +68,10 @@ public class ItemEdible extends ItemFood {
|
||||
|
||||
@Override
|
||||
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
|
||||
if (!worldIn.isRemote)
|
||||
{
|
||||
if(!worldIn.isRemote) {
|
||||
for(PotionEffect potion : potionEffects.get(stack.getMetadata())) {
|
||||
player.addPotionEffect(new PotionEffect(potion.getPotion(), potion.getDuration(), potion.getAmplifier(), potion.getIsAmbient(), potion.doesShowParticles()));
|
||||
player.addPotionEffect(new PotionEffect(potion.getPotion(), potion.getDuration(), potion.getAmplifier(), potion
|
||||
.getIsAmbient(), potion.doesShowParticles()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,20 +41,24 @@ public class ItemMetaDynamic extends Item {
|
||||
|
||||
/**
|
||||
* Add a valid metadata.
|
||||
* @param meta The metadata value
|
||||
* @param name The name used for registering the itemmodel as well as the unlocalized name of the meta. The unlocalized name will be lowercased and stripped of whitespaces.
|
||||
*
|
||||
* @param meta The metadata value
|
||||
* @param name The name used for registering the itemmodel as well as the unlocalized name of the meta. The unlocalized name will be lowercased and stripped of whitespaces.
|
||||
* @return An itemstack representing the Item-Meta combination.
|
||||
*/
|
||||
public ItemStack addMeta(int meta, String name) {
|
||||
if(meta > MAX) {
|
||||
throw new IllegalArgumentException(String.format("Metadata for %s too high, highest supported value is %d. Meta was %d", name, MAX, meta));
|
||||
throw new IllegalArgumentException(String
|
||||
.format("Metadata for %s too high, highest supported value is %d. Meta was %d", name, MAX, meta));
|
||||
}
|
||||
else if(isValid(meta)) {
|
||||
throw new IllegalArgumentException(String.format("Metadata for %s is already taken. Meta %d is %s", name, meta, names.get(meta)));
|
||||
throw new IllegalArgumentException(String
|
||||
.format("Metadata for %s is already taken. Meta %d is %s", name, meta, names
|
||||
.get(meta)));
|
||||
}
|
||||
|
||||
while(meta >= availabilityMask.length) {
|
||||
availabilityMask = Arrays.copyOf(availabilityMask, availabilityMask.length*2);
|
||||
availabilityMask = Arrays.copyOf(availabilityMask, availabilityMask.length * 2);
|
||||
}
|
||||
setValid(meta);
|
||||
names.put(meta, name);
|
||||
@@ -64,10 +68,12 @@ public class ItemMetaDynamic extends Item {
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
int meta = stack.getMetadata(); // should call getMetadata below
|
||||
if(isValid(meta))
|
||||
if(isValid(meta)) {
|
||||
return super.getUnlocalizedName(stack) + "." + LocUtils.makeLocString(names.get(meta));
|
||||
else
|
||||
}
|
||||
else {
|
||||
return super.getUnlocalizedName(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,11 +2,12 @@ package slimeknights.mantle.multiblock;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IMasterLogic
|
||||
{
|
||||
/** Called when servants change their state
|
||||
*
|
||||
* @param pos servant position
|
||||
*/
|
||||
void notifyChange(IServantLogic servant, BlockPos pos);
|
||||
public interface IMasterLogic {
|
||||
|
||||
/**
|
||||
* Called when servants change their state
|
||||
*
|
||||
* @param pos servant position
|
||||
*/
|
||||
void notifyChange(IServantLogic servant, BlockPos pos);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package slimeknights.mantle.multiblock;
|
||||
|
||||
public interface IMasterNode extends IMasterLogic, IServantLogic
|
||||
{
|
||||
boolean isCurrentlyMaster();
|
||||
public interface IMasterNode extends IMasterLogic, IServantLogic {
|
||||
|
||||
boolean isEquivalentMaster(IMasterLogic master);
|
||||
boolean isCurrentlyMaster();
|
||||
|
||||
boolean isEquivalentMaster(IMasterLogic master);
|
||||
}
|
||||
@@ -3,39 +3,37 @@ package slimeknights.mantle.multiblock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IServantLogic
|
||||
{
|
||||
BlockPos getMasterPosition();
|
||||
public interface IServantLogic {
|
||||
|
||||
/** The block should already have a valid master */
|
||||
void notifyMasterOfChange();
|
||||
BlockPos getMasterPosition();
|
||||
|
||||
/** Checks if this block can be tied to this master
|
||||
*
|
||||
* @param master
|
||||
* @param world the world of master
|
||||
* @param pos position of master
|
||||
* @return whether the servant can be tied to this master
|
||||
*/
|
||||
/** The block should already have a valid master */
|
||||
void notifyMasterOfChange();
|
||||
|
||||
boolean setPotentialMaster(IMasterLogic master, World world, BlockPos pos);
|
||||
/**
|
||||
* Checks if this block can be tied to this master
|
||||
*
|
||||
* @param world the world of master
|
||||
* @param pos position of master
|
||||
* @return whether the servant can be tied to this master
|
||||
*/
|
||||
|
||||
/** Used to set and verify that this is the block's master
|
||||
*
|
||||
* @param master
|
||||
* @param world
|
||||
* @param pos position of master
|
||||
* @return Is this block tied to this master?
|
||||
*/
|
||||
boolean setPotentialMaster(IMasterLogic master, World world, BlockPos pos);
|
||||
|
||||
boolean verifyMaster(IMasterLogic master, World world, BlockPos pos);
|
||||
/**
|
||||
* Used to set and verify that this is the block's master
|
||||
*
|
||||
* @param pos position of master
|
||||
* @return Is this block tied to this master?
|
||||
*/
|
||||
|
||||
/** Exactly what it says on the tin
|
||||
*
|
||||
* @param master
|
||||
* @param world
|
||||
* @param pos position of master
|
||||
*/
|
||||
boolean verifyMaster(IMasterLogic master, World world, BlockPos pos);
|
||||
|
||||
void invalidateMaster(IMasterLogic master, World world, BlockPos pos);
|
||||
/**
|
||||
* Exactly what it says on the tin
|
||||
*
|
||||
* @param pos position of master
|
||||
*/
|
||||
|
||||
void invalidateMaster(IMasterLogic master, World world, BlockPos pos);
|
||||
}
|
||||
@@ -7,191 +7,166 @@ import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
|
||||
public class MultiServantLogic extends TileEntity implements IServantLogic
|
||||
{
|
||||
boolean hasMaster;
|
||||
public class MultiServantLogic extends TileEntity implements IServantLogic {
|
||||
|
||||
BlockPos master;
|
||||
boolean hasMaster;
|
||||
|
||||
Block masterBlock;
|
||||
BlockPos master;
|
||||
|
||||
IBlockState state;
|
||||
Block masterBlock;
|
||||
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
IBlockState state;
|
||||
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getHasMaster() {
|
||||
return this.hasMaster;
|
||||
}
|
||||
|
||||
public boolean hasValidMaster() {
|
||||
if(!this.hasMaster) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getHasMaster()
|
||||
{
|
||||
return this.hasMaster;
|
||||
if(this.worldObj.getBlockState(this.master).getBlock() == this.masterBlock && this.worldObj
|
||||
.getBlockState(this.master) == this.state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasValidMaster()
|
||||
{
|
||||
if (!this.hasMaster)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.worldObj.getBlockState(this.master).getBlock() == this.masterBlock && this.worldObj.getBlockState(this.master) == this.state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.hasMaster = false;
|
||||
this.master = null;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
this.hasMaster = false;
|
||||
this.master = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getMasterPosition()
|
||||
{
|
||||
return this.master;
|
||||
}
|
||||
@Override
|
||||
public BlockPos getMasterPosition() {
|
||||
return this.master;
|
||||
}
|
||||
|
||||
public void overrideMaster(BlockPos pos)
|
||||
{
|
||||
this.hasMaster = true;
|
||||
this.master = pos;
|
||||
this.state = this.worldObj.getBlockState(this.master);
|
||||
this.masterBlock = this.state.getBlock();
|
||||
}
|
||||
public void overrideMaster(BlockPos pos) {
|
||||
this.hasMaster = true;
|
||||
this.master = pos;
|
||||
this.state = this.worldObj.getBlockState(this.master);
|
||||
this.masterBlock = this.state.getBlock();
|
||||
}
|
||||
|
||||
public void removeMaster()
|
||||
{
|
||||
this.hasMaster = false;
|
||||
this.master = null;
|
||||
this.masterBlock = null;
|
||||
this.state = null;
|
||||
}
|
||||
public void removeMaster() {
|
||||
this.hasMaster = false;
|
||||
this.master = null;
|
||||
this.masterBlock = null;
|
||||
this.state = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPotentialMaster(IMasterLogic master, World w, BlockPos pos)
|
||||
{
|
||||
return !this.hasMaster;
|
||||
}
|
||||
@Override
|
||||
public boolean setPotentialMaster(IMasterLogic master, World w, BlockPos pos) {
|
||||
return !this.hasMaster;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean verifyMaster(IMasterLogic logic, BlockPos pos)
|
||||
{
|
||||
return this.master.equals(pos) && this.worldObj.getBlockState(pos) == this.state && this.worldObj.getBlockState(pos).getBlock() == this.masterBlock;
|
||||
}
|
||||
@Deprecated
|
||||
public boolean verifyMaster(IMasterLogic logic, BlockPos pos) {
|
||||
return this.master.equals(pos) && this.worldObj.getBlockState(pos) == this.state && this.worldObj.getBlockState(pos)
|
||||
.getBlock() == this.masterBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyMaster(IMasterLogic logic, World world, BlockPos pos)
|
||||
{
|
||||
if (this.hasMaster)
|
||||
{
|
||||
return this.hasValidMaster();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.overrideMaster(pos);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean verifyMaster(IMasterLogic logic, World world, BlockPos pos) {
|
||||
if(this.hasMaster) {
|
||||
return this.hasValidMaster();
|
||||
}
|
||||
else {
|
||||
this.overrideMaster(pos);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateMaster(IMasterLogic master, World w, BlockPos pos)
|
||||
{
|
||||
this.hasMaster = false;
|
||||
master = null;
|
||||
}
|
||||
@Override
|
||||
public void invalidateMaster(IMasterLogic master, World w, BlockPos pos) {
|
||||
this.hasMaster = false;
|
||||
master = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyMasterOfChange()
|
||||
{
|
||||
if (this.hasValidMaster())
|
||||
{
|
||||
IMasterLogic logic = (IMasterLogic) this.worldObj.getTileEntity(this.master);
|
||||
logic.notifyChange(this, this.pos);
|
||||
}
|
||||
@Override
|
||||
public void notifyMasterOfChange() {
|
||||
if(this.hasValidMaster()) {
|
||||
IMasterLogic logic = (IMasterLogic) this.worldObj.getTileEntity(this.master);
|
||||
logic.notifyChange(this, this.pos);
|
||||
}
|
||||
}
|
||||
|
||||
public void readCustomNBT(NBTTagCompound tags)
|
||||
{
|
||||
this.hasMaster = tags.getBoolean("hasMaster");
|
||||
if (this.hasMaster)
|
||||
{
|
||||
int xCenter = tags.getInteger("xCenter");
|
||||
int yCenter = tags.getInteger("yCenter");
|
||||
int zCenter = tags.getInteger("zCenter");
|
||||
this.master = new BlockPos(xCenter, yCenter, zCenter);
|
||||
this.masterBlock = GameData.getBlockRegistry().getObject(new ResourceLocation(tags.getString("MasterBlockName")));
|
||||
this.state = Block.getStateById(tags.getInteger("masterState"));
|
||||
}
|
||||
public void readCustomNBT(NBTTagCompound tags) {
|
||||
this.hasMaster = tags.getBoolean("hasMaster");
|
||||
if(this.hasMaster) {
|
||||
int xCenter = tags.getInteger("xCenter");
|
||||
int yCenter = tags.getInteger("yCenter");
|
||||
int zCenter = tags.getInteger("zCenter");
|
||||
this.master = new BlockPos(xCenter, yCenter, zCenter);
|
||||
this.masterBlock = GameData.getBlockRegistry().getObject(new ResourceLocation(tags.getString("MasterBlockName")));
|
||||
this.state = Block.getStateById(tags.getInteger("masterState"));
|
||||
}
|
||||
}
|
||||
|
||||
public void writeCustomNBT(NBTTagCompound tags)
|
||||
{
|
||||
tags.setBoolean("hasMaster", this.hasMaster);
|
||||
if (this.hasMaster)
|
||||
{
|
||||
tags.setInteger("xCenter", this.master.getX());
|
||||
tags.setInteger("yCenter", this.master.getY());
|
||||
tags.setInteger("zCenter", this.master.getZ());
|
||||
tags.setString("MasterBlockName", GameData.getBlockRegistry().getNameForObject(this.masterBlock).toString());
|
||||
tags.setInteger("masterState", Block.getStateId(this.state));
|
||||
}
|
||||
public void writeCustomNBT(NBTTagCompound tags) {
|
||||
tags.setBoolean("hasMaster", this.hasMaster);
|
||||
if(this.hasMaster) {
|
||||
tags.setInteger("xCenter", this.master.getX());
|
||||
tags.setInteger("yCenter", this.master.getY());
|
||||
tags.setInteger("zCenter", this.master.getZ());
|
||||
tags.setString("MasterBlockName", GameData.getBlockRegistry().getNameForObject(this.masterBlock).toString());
|
||||
tags.setInteger("masterState", Block.getStateId(this.state));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
this.readCustomNBT(tags);
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tags) {
|
||||
super.readFromNBT(tags);
|
||||
this.readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
this.writeCustomNBT(tags);
|
||||
}
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tags) {
|
||||
super.writeToNBT(tags);
|
||||
this.writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.writeCustomNBT(tag);
|
||||
return new SPacketUpdateTileEntity(this.pos, 1, tag);
|
||||
}
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.writeCustomNBT(tag);
|
||||
return new SPacketUpdateTileEntity(this.pos, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet)
|
||||
{
|
||||
this.readCustomNBT(packet.getNbtCompound());
|
||||
this.worldObj.notifyLightSet(this.pos);
|
||||
this.worldObj.notifyBlockUpdate(this.pos, state, state, 3);
|
||||
}
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
this.readCustomNBT(packet.getNbtCompound());
|
||||
this.worldObj.notifyLightSet(this.pos);
|
||||
this.worldObj.notifyBlockUpdate(this.pos, state, state, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return this.worldObj;
|
||||
}
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.worldObj;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean setMaster(BlockPos pos)
|
||||
{
|
||||
if (!this.hasMaster || this.worldObj.getBlockState(this.master) != this.state || (this.worldObj.getBlockState(this.master).getBlock() != this.masterBlock))
|
||||
{
|
||||
this.overrideMaster(pos);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Deprecated
|
||||
public boolean setMaster(BlockPos pos) {
|
||||
if(!this.hasMaster || this.worldObj.getBlockState(this.master) != this.state || (this.worldObj
|
||||
.getBlockState(this.master)
|
||||
.getBlock() != this.masterBlock)) {
|
||||
this.overrideMaster(pos);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package slimeknights.mantle.network;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,6 +49,7 @@ public class NetworkWrapper {
|
||||
}
|
||||
|
||||
public static class AbstactPacketHandler implements IMessageHandler<AbstractPacket, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(AbstractPacket packet, MessageContext ctx) {
|
||||
if(ctx.side == Side.SERVER) {
|
||||
|
||||
@@ -7,9 +7,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package slimeknights.mantle.util;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
|
||||
import mezz.jei.api.IItemRegistry;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.IJeiRuntime;
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.IRecipeRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import mezz.jei.api.gui.IAdvancedGuiHandler;
|
||||
import slimeknights.mantle.client.gui.GuiMultiModule;
|
||||
@@ -36,5 +34,6 @@ public class JeiPlugin implements IModPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {}
|
||||
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,9 @@ import java.util.Locale;
|
||||
|
||||
// localization utils
|
||||
public abstract class LocUtils {
|
||||
private LocUtils() {}
|
||||
|
||||
private LocUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all whitespaces from the string and makes it lowercase.
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package slimeknights.mantle.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Queues;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -137,7 +136,8 @@ public class RecipeMatchRegistry {
|
||||
|
||||
public static RecipeComparator INSTANCE = new RecipeComparator();
|
||||
|
||||
private RecipeComparator() {}
|
||||
private RecipeComparator() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(RecipeMatch o1, RecipeMatch o2) {
|
||||
|
||||
@@ -12,83 +12,67 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class RecipeRemover
|
||||
{
|
||||
public static void removeShapedRecipes(List<ItemStack> removelist)
|
||||
{
|
||||
for (ItemStack stack : removelist)
|
||||
{
|
||||
removeShapedRecipe(stack);
|
||||
public class RecipeRemover {
|
||||
|
||||
public static void removeShapedRecipes(List<ItemStack> removelist) {
|
||||
for(ItemStack stack : removelist) {
|
||||
removeShapedRecipe(stack);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeAnyRecipe(ItemStack resultItem) {
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for(int i = 0; i < recipes.size(); i++) {
|
||||
IRecipe tmpRecipe = recipes.get(i);
|
||||
ItemStack recipeResult = tmpRecipe.getRecipeOutput();
|
||||
if(ItemStack.areItemStacksEqual(resultItem, recipeResult)) {
|
||||
recipes.remove(i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeShapedRecipe(ItemStack resultItem) {
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for(int i = 0; i < recipes.size(); i++) {
|
||||
IRecipe tmpRecipe = recipes.get(i);
|
||||
if(tmpRecipe instanceof ShapedRecipes) {
|
||||
ShapedRecipes recipe = (ShapedRecipes) tmpRecipe;
|
||||
ItemStack recipeResult = recipe.getRecipeOutput();
|
||||
|
||||
if(ItemStack.areItemStacksEqual(resultItem, recipeResult)) {
|
||||
recipes.remove(i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeAnyRecipe(ItemStack resultItem)
|
||||
{
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (int i = 0; i < recipes.size(); i++)
|
||||
{
|
||||
IRecipe tmpRecipe = recipes.get(i);
|
||||
ItemStack recipeResult = tmpRecipe.getRecipeOutput();
|
||||
if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
|
||||
{
|
||||
recipes.remove(i--);
|
||||
}
|
||||
public static void removeShapelessRecipe(ItemStack resultItem) {
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for(int i = 0; i < recipes.size(); i++) {
|
||||
IRecipe tmpRecipe = recipes.get(i);
|
||||
if(tmpRecipe instanceof ShapelessRecipes) {
|
||||
ShapelessRecipes recipe = (ShapelessRecipes) tmpRecipe;
|
||||
ItemStack recipeResult = recipe.getRecipeOutput();
|
||||
|
||||
if(ItemStack.areItemStacksEqual(resultItem, recipeResult)) {
|
||||
recipes.remove(i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeShapedRecipe(ItemStack resultItem)
|
||||
{
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (int i = 0; i < recipes.size(); i++)
|
||||
{
|
||||
IRecipe tmpRecipe = recipes.get(i);
|
||||
if (tmpRecipe instanceof ShapedRecipes)
|
||||
{
|
||||
ShapedRecipes recipe = (ShapedRecipes) tmpRecipe;
|
||||
ItemStack recipeResult = recipe.getRecipeOutput();
|
||||
public static void removeFurnaceRecipe(ItemStack resultItem) {
|
||||
Map<ItemStack, ItemStack> recipes = FurnaceRecipes.instance().getSmeltingList();
|
||||
recipes.remove(resultItem);
|
||||
}
|
||||
|
||||
if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
|
||||
{
|
||||
recipes.remove(i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void removeFurnaceRecipe(Item i, int metadata) {
|
||||
removeFurnaceRecipe(new ItemStack(i, 1, metadata));
|
||||
}
|
||||
|
||||
public static void removeShapelessRecipe(ItemStack resultItem)
|
||||
{
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (int i = 0; i < recipes.size(); i++)
|
||||
{
|
||||
IRecipe tmpRecipe = recipes.get(i);
|
||||
if (tmpRecipe instanceof ShapelessRecipes)
|
||||
{
|
||||
ShapelessRecipes recipe = (ShapelessRecipes) tmpRecipe;
|
||||
ItemStack recipeResult = recipe.getRecipeOutput();
|
||||
|
||||
if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
|
||||
{
|
||||
recipes.remove(i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeFurnaceRecipe(ItemStack resultItem)
|
||||
{
|
||||
Map<ItemStack, ItemStack> recipes = FurnaceRecipes.instance().getSmeltingList();
|
||||
recipes.remove(resultItem);
|
||||
}
|
||||
|
||||
public static void removeFurnaceRecipe(Item i, int metadata)
|
||||
{
|
||||
removeFurnaceRecipe(new ItemStack(i, 1, metadata));
|
||||
}
|
||||
|
||||
public static void removeFurnaceRecipe(Item i)
|
||||
{
|
||||
removeFurnaceRecipe(new ItemStack(i, 1, 32767));
|
||||
}
|
||||
public static void removeFurnaceRecipe(Item i) {
|
||||
removeFurnaceRecipe(new ItemStack(i, 1, 32767));
|
||||
}
|
||||
/*
|
||||
// todo: 1.9
|
||||
//removes from all vanilla worldgen chests :D
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
|
||||
public class TagHelper {
|
||||
|
||||
public static int TAG_TYPE_STRING = (new NBTTagString()).getId();
|
||||
public static int TAG_TYPE_COMPOUND = (new NBTTagCompound()).getId();
|
||||
|
||||
|
||||
Reference in new issue
Block a user