Format so style is finally consistent.

This commit is contained in:
Shadows_of_Fire 2019-05-02 03:10:29 -04:00
parent 95a25dbfc4
commit 274c53a014
387 changed files with 7603 additions and 8941 deletions

View file

@ -39,10 +39,10 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
public final class ActuallyAdditionsAPI{
public final class ActuallyAdditionsAPI {
public static final String MOD_ID = "actuallyadditions";
public static final String API_ID = MOD_ID+"api";
public static final String API_ID = MOD_ID + "api";
public static final String API_VERSION = "34";
public static final List<CrusherRecipe> CRUSHER_RECIPES = new ArrayList<>();
@ -116,7 +116,7 @@ public final class ActuallyAdditionsAPI{
* @param oreName The ore's name
* @param weight The ore's weight
*/
public static void addMiningLensStoneOre(String oreName, int weight){
public static void addMiningLensStoneOre(String oreName, int weight) {
STONE_ORES.add(new WeightedOre(oreName, weight));
}
@ -127,7 +127,7 @@ public final class ActuallyAdditionsAPI{
* @param oreName The ore's name
* @param weight The ore's weight
*/
public static void addMiningLensNetherOre(String oreName, int weight){
public static void addMiningLensNetherOre(String oreName, int weight) {
NETHERRACK_ORES.add(new WeightedOre(oreName, weight));
}
@ -139,7 +139,7 @@ public final class ActuallyAdditionsAPI{
* @param outputTwo The second output as an ItemStack (can be ItemStack.EMPTY if there should be none)
* @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time)
*/
public static void addCrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance){
public static void addCrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance) {
CRUSHER_RECIPES.add(new CrusherRecipe(Ingredient.fromStacks(input), outputOne, outputTwo.isEmpty() ? ItemStack.EMPTY : outputTwo, outputTwoChance));
}
@ -151,7 +151,7 @@ public final class ActuallyAdditionsAPI{
* @param outputTwo The second output as an ItemStack (can be ItemStack.EMPTY if there should be none)
* @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time)
*/
public static void addCrusherRecipe(Ingredient input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance){
public static void addCrusherRecipe(Ingredient input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance) {
CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne, outputTwo.isEmpty() ? ItemStack.EMPTY : outputTwo, outputTwoChance));
}
@ -166,13 +166,13 @@ public final class ActuallyAdditionsAPI{
* @param outputTwoAmounts The amount of the second output, will be equal for all entries in the list
* @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time)
*/
public static boolean addCrusherRecipes(List<ItemStack> inputs, List<ItemStack> outputOnes, int outputOneAmounts, List<ItemStack> outputTwos, int outputTwoAmounts, int outputTwoChance){
public static boolean addCrusherRecipes(List<ItemStack> inputs, List<ItemStack> outputOnes, int outputOneAmounts, List<ItemStack> outputTwos, int outputTwoAmounts, int outputTwoChance) {
return methodHandler.addCrusherRecipes(inputs, outputOnes, outputOneAmounts, outputTwos, outputTwoAmounts, outputTwoChance);
}
//Same thing as above, but with ItemStack outputs.
@Deprecated //Use Ingredient
public static boolean addCrusherRecipes(List<ItemStack> inputs, ItemStack outputOne, int outputOneAmount, ItemStack outputTwo, int outputTwoAmount, int outputTwoChance){
public static boolean addCrusherRecipes(List<ItemStack> inputs, ItemStack outputOne, int outputOneAmount, ItemStack outputTwo, int outputTwoAmount, int outputTwoChance) {
return methodHandler.addCrusherRecipes(inputs, outputOne, outputOneAmount, outputTwo, outputTwoAmount, outputTwoChance);
}
@ -182,7 +182,7 @@ public final class ActuallyAdditionsAPI{
* @param fluidName The name of the fluid to be consumed
* @param genAmount The amount of energy generated per operation
*/
public static void addOilGenRecipe(String fluidName, int genAmount){
public static void addOilGenRecipe(String fluidName, int genAmount) {
addOilGenRecipe(fluidName, genAmount, 100);
}
@ -192,7 +192,7 @@ public final class ActuallyAdditionsAPI{
* @param fluidName The name of the fluid to be consumed
* @param genAmount The amount of energy generated per operation
*/
public static void addOilGenRecipe(String fluidName, int genAmount, int genTime){
public static void addOilGenRecipe(String fluidName, int genAmount, int genTime) {
OIL_GENERATOR_RECIPES.add(new OilGenRecipe(fluidName, genAmount, genTime));
}
@ -205,7 +205,7 @@ public final class ActuallyAdditionsAPI{
* @param outputDisplay The block to display when there is output in the compost
*/
@Deprecated
public static void addCompostRecipe(ItemStack input, Block inputDisplay, ItemStack output, Block outputDisplay){
public static void addCompostRecipe(ItemStack input, Block inputDisplay, ItemStack output, Block outputDisplay) {
COMPOST_RECIPES.add(new CompostRecipe(input, inputDisplay, output, outputDisplay));
}
@ -217,7 +217,7 @@ public final class ActuallyAdditionsAPI{
* @param output The itemstack to be output from the compost once conversion finishes
* @param outputDisplay The state to display when there is output in the compost
*/
public static void addCompostRecipe(Ingredient input, IBlockState inputDisplay, ItemStack output, IBlockState outputDisplay){
public static void addCompostRecipe(Ingredient input, IBlockState inputDisplay, ItemStack output, IBlockState outputDisplay) {
COMPOST_RECIPES.add(new CompostRecipe(input, inputDisplay, output, outputDisplay));
}
@ -227,7 +227,7 @@ public final class ActuallyAdditionsAPI{
* @param stack The ItemStack to be returned
* @param chance The chance (this is from WeightedRandom.Item)
*/
public static void addBallOfFurReturnItem(ItemStack stack, int chance){
public static void addBallOfFurReturnItem(ItemStack stack, int chance) {
BALL_OF_FUR_RETURN_ITEMS.add(new BallOfFurReturn(stack, chance));
}
@ -239,16 +239,16 @@ public final class ActuallyAdditionsAPI{
* @param minAmount The minimum stacksize of the returned stack
* @param maxAmount The maximum stacksize of the returned stack
*/
public static void addTreasureChestLoot(ItemStack stack, int chance, int minAmount, int maxAmount){
public static void addTreasureChestLoot(ItemStack stack, int chance, int minAmount, int maxAmount) {
TREASURE_CHEST_LOOT.add(new TreasureChestLoot(stack, chance, minAmount, maxAmount));
}
@Deprecated
public static void addEmpowererRecipe(ItemStack input, ItemStack output, ItemStack modifier1, ItemStack modifier2, ItemStack modifier3, ItemStack modifier4, int energyPerStand, int time, float[] particleColor){
public static void addEmpowererRecipe(ItemStack input, ItemStack output, ItemStack modifier1, ItemStack modifier2, ItemStack modifier3, ItemStack modifier4, int energyPerStand, int time, float[] particleColor) {
EMPOWERER_RECIPES.add(new EmpowererRecipe(input, output, modifier1, modifier2, modifier3, modifier4, energyPerStand, time, particleColor));
}
public static void addEmpowererRecipe(Ingredient input, ItemStack output, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3, Ingredient modifier4, int energyPerStand, int time, float[] particleColor){
public static void addEmpowererRecipe(Ingredient input, ItemStack output, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3, Ingredient modifier4, int energyPerStand, int time, float[] particleColor) {
EMPOWERER_RECIPES.add(new EmpowererRecipe(input, output, modifier1, modifier2, modifier3, modifier4, energyPerStand, time, particleColor));
}
@ -263,12 +263,12 @@ public final class ActuallyAdditionsAPI{
* Note how this always has to be the same instance of the lens type that the item also has for it to work!
*/
@Deprecated
public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse, LensConversion type){
public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse, LensConversion type) {
RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type));
}
@Deprecated
public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse){
public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse) {
addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
}
@ -282,11 +282,11 @@ public final class ActuallyAdditionsAPI{
* @param type The type of lens used for the conversion. To use the default type, use method below.
* Note how this always has to be the same instance of the lens type that the item also has for it to work!
*/
public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse, LensConversion type){
public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse, LensConversion type) {
RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type));
}
public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse){
public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse) {
addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
}
@ -299,7 +299,7 @@ public final class ActuallyAdditionsAPI{
* @param item The item (or block's item) to add
* @param changer The change mechanism
*/
public static void addReconstructorLensColorChangeItem(Item item, IColorLensChanger changer){
public static void addReconstructorLensColorChangeItem(Item item, IColorLensChanger changer) {
RECONSTRUCTOR_LENS_COLOR_CHANGERS.put(item, changer);
}
@ -308,7 +308,7 @@ public final class ActuallyAdditionsAPI{
*
* @param ingredient The ingredient to add
*/
public static void addCoffeeMachineIngredient(CoffeeIngredient ingredient){
public static void addCoffeeMachineIngredient(CoffeeIngredient ingredient) {
COFFEE_MACHINE_INGREDIENTS.add(ingredient);
}
@ -317,7 +317,7 @@ public final class ActuallyAdditionsAPI{
*
* @param entry The entry to add
*/
public static void addBookletEntry(IBookletEntry entry){
public static void addBookletEntry(IBookletEntry entry) {
BOOKLET_ENTRIES.add(entry);
}
@ -326,7 +326,7 @@ public final class ActuallyAdditionsAPI{
*
* @param behavior The behavior to add
*/
public static void addFarmerBehavior(IFarmerBehavior behavior){
public static void addFarmerBehavior(IFarmerBehavior behavior) {
FARMER_BEHAVIORS.add(behavior);
}
}

View file

@ -14,7 +14,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public interface IBookletChapter{
public interface IBookletChapter {
IBookletPage[] getAllPages();

View file

@ -10,12 +10,12 @@
package de.ellpeck.actuallyadditions.api.booklet;
import java.util.List;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public interface IBookletEntry{
public interface IBookletEntry {
List<IBookletChapter> getAllChapters();

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.api.booklet;
import java.util.List;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
@ -17,9 +19,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public interface IBookletPage{
public interface IBookletPage {
void getItemStacksForPage(List<ItemStack> list);

View file

@ -10,13 +10,13 @@
package de.ellpeck.actuallyadditions.api.booklet.internal;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.ItemStack;
import java.util.List;
public abstract class GuiBookletBase extends GuiScreen{
public abstract class GuiBookletBase extends GuiScreen {
public abstract void renderScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale);

View file

@ -19,7 +19,7 @@ import net.minecraft.util.EnumFacing;
* This is not supposed to be implemented.
* Can be cast to TileEntity.
*/
public interface IAtomicReconstructor extends IEnergyTile{
public interface IAtomicReconstructor extends IEnergyTile {
Lens getLens();

View file

@ -17,7 +17,7 @@ import net.minecraft.world.World;
* This is not supposed to be implemented.
* Can be cast to TileEntity.
*/
public interface IEnergyTile{
public interface IEnergyTile {
BlockPos getPosition();

View file

@ -10,18 +10,18 @@
package de.ellpeck.actuallyadditions.api.internal;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import java.util.List;
/**
* This is a helper interface for IFarmerBehavior.
* <p>
* This is not supposed to be implemented.
* Can be cast to TileEntity.
*/
public interface IFarmer extends IEnergyTile{
public interface IFarmer extends IEnergyTile {
EnumFacing getOrientation();

View file

@ -28,7 +28,7 @@ import net.minecraft.util.math.BlockPos;
* Use ActuallyAdditionsAPI.methodHandler for calling
* This is not supposed to be implemented.
*/
public interface IMethodHandler{
public interface IMethodHandler {
boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient);
@ -43,6 +43,7 @@ public interface IMethodHandler{
boolean invokeConversionLens(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile);
boolean invokeReconstructor(IAtomicReconstructor tile);
boolean addCrusherRecipes(List<ItemStack> inputs, List<ItemStack> outputOnes, int outputOneAmounts, List<ItemStack> outputTwos, int outputTwoAmounts, int outputTwoChance);
@Deprecated //Use Ingredient input on AA API class

View file

@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.api.laser;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
public interface IConnectionPair{
public interface IConnectionPair {
void writeToNBT(NBTTagCompound compound);

View file

@ -23,7 +23,7 @@ import net.minecraft.world.World;
* The network system is built in a way that doesn't need the individual
* positions to be Laser Relays, it relies only on BlockPos
*/
public interface ILaserRelayConnectionHandler{
public interface ILaserRelayConnectionHandler {
ConcurrentSet<IConnectionPair> getConnectionsFor(BlockPos relay, World world);

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.api.laser;
public enum LaserType{
ENERGY, ITEM, FLUID
public enum LaserType {
ENERGY,
ITEM,
FLUID
}

View file

@ -12,22 +12,20 @@ package de.ellpeck.actuallyadditions.api.laser;
import io.netty.util.internal.ConcurrentSet;
public class Network{
public class Network {
public final ConcurrentSet<IConnectionPair> connections = new ConcurrentSet<>();
public int changeAmount;
@Override
public String toString(){
public String toString() {
return this.connections.toString();
}
@Override
public boolean equals(Object obj){
if(obj instanceof Network){
if(this.connections.equals(((Network)obj).connections)){
return true;
}
public boolean equals(Object obj) {
if (obj instanceof Network) {
if (this.connections.equals(((Network) obj).connections)) { return true; }
}
return super.equals(obj);
}

View file

@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.api.lens;
/**
* This is the base class for a Reconstructor Lens Item
*/
public interface ILensItem{
public interface ILensItem {
/**
* Returns the lens type that belongs to this lens item

View file

@ -18,7 +18,7 @@ import net.minecraft.util.math.BlockPos;
/**
* This is the base class for a Reconstructor Lens Type (NOT THE ITEM!)
*/
public abstract class Lens{
public abstract class Lens {
/**
* Invokes the lens type's behavior on a block
@ -42,7 +42,7 @@ public abstract class Lens{
/**
* @return If the lens can be invoked at the current time
*/
public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot){
public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot) {
return true;
}
}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.api.lens;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import net.minecraft.block.state.IBlockState;
@ -23,20 +22,20 @@ import net.minecraft.util.math.BlockPos;
* If you want to make a new type of conversion, just use your type in the recipe
* If you want to use the default type of conversion, use ActuallyAdditionsAPI.lensDefaultConversion.
*/
public class LensConversion extends Lens{
public class LensConversion extends Lens {
@Override
public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){
public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) {
return ActuallyAdditionsAPI.methodHandler.invokeConversionLens(hitState, hitBlock, tile);
}
@Override
public float[] getColor(){
return new float[]{27F/255F, 109F/255F, 1F};
public float[] getColor() {
return new float[] { 27F / 255F, 109F / 255F, 1F };
}
@Override
public int getDistance(){
public int getDistance() {
return 10;
}

View file

@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.api.misc;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
public interface IDisplayStandItem{
public interface IDisplayStandItem {
boolean update(ItemStack stack, TileEntity tile, int elapsedTicks);

View file

@ -10,7 +10,7 @@
package de.ellpeck.actuallyadditions.api.misc;
public interface IGoggles{
public interface IGoggles {
boolean displaySpectralMobs();

View file

@ -13,11 +13,11 @@ package de.ellpeck.actuallyadditions.api.recipe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandom;
public class BallOfFurReturn extends WeightedRandom.Item{
public class BallOfFurReturn extends WeightedRandom.Item {
public final ItemStack returnItem;
public BallOfFurReturn(ItemStack returnItem, int chance){
public BallOfFurReturn(ItemStack returnItem, int chance) {
super(chance);
this.returnItem = returnItem;
}

View file

@ -15,7 +15,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
public class CompostRecipe{
public class CompostRecipe {
protected final Ingredient input;
protected final ItemStack output;
@ -27,7 +27,7 @@ public class CompostRecipe{
this(Ingredient.fromStacks(input), inputDisplay.getDefaultState(), output, outputDisplay.getDefaultState());
}
public CompostRecipe(Ingredient input, IBlockState inputDisplay, ItemStack output, IBlockState outputDisplay){
public CompostRecipe(Ingredient input, IBlockState inputDisplay, ItemStack output, IBlockState outputDisplay) {
this.input = input;
this.output = output;
this.inputDisplay = inputDisplay;

View file

@ -22,7 +22,7 @@ import net.minecraft.util.math.BlockPos;
* <p>
* See ColorLensChangerByDyeMeta for reference.
*/
public interface IColorLensChanger{
public interface IColorLensChanger {
/**
* Modifies the given item.

View file

@ -10,7 +10,7 @@
package de.ellpeck.actuallyadditions.api.recipe;
public class OilGenRecipe{
public class OilGenRecipe {
public final String fluidName;
public final int genAmount;
@ -22,7 +22,7 @@ public class OilGenRecipe{
* @param genAmount The power generated, in CF/t
* @param genTime The length the fluid burns for, in seconds
*/
public OilGenRecipe(String fluidName, int genAmount, int genTime){
public OilGenRecipe(String fluidName, int genAmount, int genTime) {
this.fluidName = fluidName;
this.genAmount = genAmount;
this.genTime = genTime;

View file

@ -13,13 +13,13 @@ package de.ellpeck.actuallyadditions.api.recipe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandom;
public class TreasureChestLoot extends WeightedRandom.Item{
public class TreasureChestLoot extends WeightedRandom.Item {
public final ItemStack returnItem;
public final int minAmount;
public final int maxAmount;
public TreasureChestLoot(ItemStack returnItem, int chance, int minAmount, int maxAmount){
public TreasureChestLoot(ItemStack returnItem, int chance, int minAmount, int maxAmount) {
super(chance);
this.returnItem = returnItem;
this.minAmount = minAmount;

View file

@ -12,11 +12,11 @@ package de.ellpeck.actuallyadditions.api.recipe;
import net.minecraft.util.WeightedRandom;
public class WeightedOre extends WeightedRandom.Item{
public class WeightedOre extends WeightedRandom.Item {
public final String name;
public WeightedOre(String name, int weight){
public WeightedOre(String name, int weight) {
super(weight);
this.name = name;
}

View file

@ -15,7 +15,7 @@ import net.minecraft.util.math.BlockPos;
/**
* Extending this will cause a TileEntity to be able to be connected via a Phantom Connector
*/
public interface IPhantomTile{
public interface IPhantomTile {
/**
* @return If the Phantom Tile is currently bound to anything

View file

@ -1,5 +1,8 @@
package de.ellpeck.actuallyadditions.mod;
import java.util.HashMap;
import java.util.Map;
import de.ellpeck.actuallyadditions.mod.blocks.render.ActualCompostModel;
import de.ellpeck.actuallyadditions.mod.blocks.render.CompostModel;
import de.ellpeck.actuallyadditions.mod.blocks.render.IHasModel;
@ -17,17 +20,14 @@ import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.HashMap;
import java.util.Map;
public class ClientRegistryHandler{
public class ClientRegistryHandler {
public static final Map<ItemStack, ModelResourceLocation> MODEL_LOCATIONS_FOR_REGISTERING = new HashMap<>();
/**
* (Excerpted from Tinkers' Construct with permission, thanks guys!)
*/
private static void registerCustomFluidBlockRenderer(Fluid fluid){
private static void registerCustomFluidBlockRenderer(Fluid fluid) {
Block block = fluid.getBlock();
Item item = Item.getItemFromBlock(block);
FluidStateMapper mapper = new FluidStateMapper(fluid);
@ -37,14 +37,14 @@ public class ClientRegistryHandler{
}
@SubscribeEvent
public void onModelRegistry(ModelRegistryEvent event){
for(Block block : RegistryHandler.BLOCKS_TO_REGISTER){
if(block instanceof IHasModel){
((IHasModel)block).registerRendering();
public void onModelRegistry(ModelRegistryEvent event) {
for (Block block : RegistryHandler.BLOCKS_TO_REGISTER) {
if (block instanceof IHasModel) {
((IHasModel) block).registerRendering();
}
}
for(Map.Entry<ItemStack, ModelResourceLocation> entry : MODEL_LOCATIONS_FOR_REGISTERING.entrySet()){
for (Map.Entry<ItemStack, ModelResourceLocation> entry : MODEL_LOCATIONS_FOR_REGISTERING.entrySet()) {
ModelLoader.setCustomModelResourceLocation(entry.getKey().getItem(), entry.getKey().getItemDamage(), entry.getValue());
}

View file

@ -1,5 +1,8 @@
package de.ellpeck.actuallyadditions.mod;
import java.util.ArrayList;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.crafting.InitCrafting;
@ -15,11 +18,8 @@ import net.minecraftforge.event.RegistryEvent.Register;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
import java.util.ArrayList;
import java.util.List;
//Class to wrap around the trainwreck that is the new registry system
public class RegistryHandler{
public class RegistryHandler {
public static final List<Block> BLOCKS_TO_REGISTER = new ArrayList<>();
public static final List<Item> ITEMS_TO_REGISTER = new ArrayList<>();
@ -27,19 +27,19 @@ public class RegistryHandler{
public static final List<IRecipe> RECIPES_TO_REGISTER = new ArrayList<>();
@SubscribeEvent
public void onBlockRegistry(Register<Block> event){
public void onBlockRegistry(Register<Block> event) {
InitBlocks.init();
for(Block block : BLOCKS_TO_REGISTER){
for (Block block : BLOCKS_TO_REGISTER) {
event.getRegistry().register(block);
}
}
@SubscribeEvent
public void onItemRegistry(Register<Item> event){
public void onItemRegistry(Register<Item> event) {
InitItems.init();
for(Item item : ITEMS_TO_REGISTER){
for (Item item : ITEMS_TO_REGISTER) {
event.getRegistry().register(item);
}
ITEMS_TO_REGISTER.clear();
@ -49,28 +49,28 @@ public class RegistryHandler{
}
@SubscribeEvent
public void onVillagerRegistry(Register<VillagerProfession> event){
public void onVillagerRegistry(Register<VillagerProfession> event) {
InitVillager.init();
if(ConfigBoolValues.JAM_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.jamProfession);
if(ConfigBoolValues.ENGINEER_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.engineerProfession);
if (ConfigBoolValues.JAM_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.jamProfession);
if (ConfigBoolValues.ENGINEER_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.engineerProfession);
}
@SubscribeEvent
public void onCraftingRegistry(Register<IRecipe> event){
public void onCraftingRegistry(Register<IRecipe> event) {
InitCrafting.init();
for(IRecipe recipe : RECIPES_TO_REGISTER){
for (IRecipe recipe : RECIPES_TO_REGISTER) {
event.getRegistry().register(recipe);
}
RECIPES_TO_REGISTER.clear();
}
@SubscribeEvent
public void onSoundRegistry(Register<SoundEvent> event){
public void onSoundRegistry(Register<SoundEvent> event) {
SoundHandler.init();
for(SoundEvent sound : SOUNDS_TO_REGISTER){
for (SoundEvent sound : SOUNDS_TO_REGISTER) {
event.getRegistry().register(sound);
}
SOUNDS_TO_REGISTER.clear();

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.List;
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
@ -47,14 +49,12 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public class BlockAtomicReconstructor extends BlockContainerBase implements IHudDisplay{
public class BlockAtomicReconstructor extends BlockContainerBase implements IHudDisplay {
public static final int NAME_FLAVOR_AMOUNTS_1 = 12;
public static final int NAME_FLAVOR_AMOUNTS_2 = 14;
public BlockAtomicReconstructor(String name){
public BlockAtomicReconstructor(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(10F);
@ -63,36 +63,33 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
ItemStack heldItem = player.getHeldItem(hand);
if(this.tryToggleRedstone(world, pos, player)){
return true;
}
if(!world.isRemote){
TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor)world.getTileEntity(pos);
if(reconstructor != null){
if(StackUtil.isValid(heldItem)){
if (this.tryToggleRedstone(world, pos, player)) { return true; }
if (!world.isRemote) {
TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor) world.getTileEntity(pos);
if (reconstructor != null) {
if (StackUtil.isValid(heldItem)) {
Item item = heldItem.getItem();
if(item instanceof ILensItem && !StackUtil.isValid(reconstructor.inv.getStackInSlot(0))){
if (item instanceof ILensItem && !StackUtil.isValid(reconstructor.inv.getStackInSlot(0))) {
ItemStack toPut = heldItem.copy();
toPut.setCount(1);
reconstructor.inv.setStackInSlot(0, toPut);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
//Shush, don't tell anyone!
else if(ConfigIntValues.ELEVEN.getValue() == 11 && item == Items.RECORD_11){
else if (ConfigIntValues.ELEVEN.getValue() == 11 && item == Items.RECORD_11) {
reconstructor.counter++;
reconstructor.markDirty();
}
}
else{
} else {
ItemStack slot = reconstructor.inv.getStackInSlot(0);
if(StackUtil.isValid(slot)){
if (StackUtil.isValid(slot)) {
player.setHeldItem(hand, slot.copy());
reconstructor.inv.setStackInSlot(0, StackUtil.getEmpty());
}
@ -102,43 +99,41 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int i){
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityAtomicReconstructor();
}
@Override
@SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) {
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
if(tile instanceof TileEntityAtomicReconstructor){
ItemStack slot = ((TileEntityAtomicReconstructor)tile).inv.getStackInSlot(0);
if (tile instanceof TileEntityAtomicReconstructor) {
ItemStack slot = ((TileEntityAtomicReconstructor) tile).inv.getStackInSlot(0);
String strg;
if(!StackUtil.isValid(slot)){
strg = StringUtil.localize("info."+ActuallyAdditions.MODID+".noLens");
}
else{
if (!StackUtil.isValid(slot)) {
strg = StringUtil.localize("info." + ActuallyAdditions.MODID + ".noLens");
} else {
strg = slot.getItem().getItemStackDisplayName(slot);
AssetUtil.renderStackToGui(slot, resolution.getScaledWidth()/2+15, resolution.getScaledHeight()/2-19, 1F);
AssetUtil.renderStackToGui(slot, resolution.getScaledWidth() / 2 + 15, resolution.getScaledHeight() / 2 - 19, 1F);
}
minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg, resolution.getScaledWidth()/2+35, resolution.getScaledHeight()/2-15, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg, resolution.getScaledWidth() / 2 + 35, resolution.getScaledHeight() / 2 - 15, StringUtil.DECIMAL_COLOR_WHITE);
}
}
@Override
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new TheItemBlock(this);
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
int rotation = EnumFacing.getDirectionFromEntityLiving(pos, player).ordinal();
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
@ -146,77 +141,76 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockDirectional.FACING).getIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockDirectional.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
}
public static class TheItemBlock extends ItemBlockBase{
public static class TheItemBlock extends ItemBlockBase {
private long lastSysTime;
private int toPick1;
private int toPick2;
public TheItemBlock(Block block){
public TheItemBlock(Block block) {
super(block);
this.setHasSubtypes(false);
this.setMaxDamage(0);
}
@Override
public String getTranslationKey(ItemStack stack){
public String getTranslationKey(ItemStack stack) {
return this.getTranslationKey();
}
@Override
public int getMetadata(int damage){
public int getMetadata(int damage) {
return damage;
}
@Override
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag advanced){
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag advanced) {
long sysTime = System.currentTimeMillis();
if(this.lastSysTime+3000 < sysTime){
if (this.lastSysTime + 3000 < sysTime) {
this.lastSysTime = sysTime;
if(world != null){
this.toPick1 = world.rand.nextInt(NAME_FLAVOR_AMOUNTS_1)+1;
this.toPick2 = world.rand.nextInt(NAME_FLAVOR_AMOUNTS_2)+1;
if (world != null) {
this.toPick1 = world.rand.nextInt(NAME_FLAVOR_AMOUNTS_1) + 1;
this.toPick2 = world.rand.nextInt(NAME_FLAVOR_AMOUNTS_2) + 1;
}
}
String base = "tile."+ActuallyAdditions.MODID+"."+((BlockAtomicReconstructor)this.block).getBaseName()+".info.";
tooltip.add(StringUtil.localize(base+"1."+this.toPick1)+" "+StringUtil.localize(base+"2."+this.toPick2));
String base = "tile." + ActuallyAdditions.MODID + "." + ((BlockAtomicReconstructor) this.block).getBaseName() + ".info.";
tooltip.add(StringUtil.localize(base + "1." + this.toPick1) + " " + StringUtil.localize(base + "2." + this.toPick2));
}
}
@Override
public boolean hasComparatorInputOverride(IBlockState state){
public boolean hasComparatorInputOverride(IBlockState state) {
return true;
}
@Override
public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos){
public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos) {
TileEntity t = world.getTileEntity(pos);
int i = 0;
if (t instanceof TileEntityAtomicReconstructor) {

View file

@ -28,9 +28,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockBatteryBox extends BlockContainerBase{
public class BlockBatteryBox extends BlockContainerBase {
public BlockBatteryBox(String name){
public BlockBatteryBox(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -39,32 +39,31 @@ public class BlockBatteryBox extends BlockContainerBase{
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return BlockSlabs.AABB_BOTTOM_HALF;
}
@Override
public TileEntity createNewTileEntity(World world, int meta){
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityBatteryBox();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityBatteryBox){
TileEntityBatteryBox box = (TileEntityBatteryBox)tile;
if (tile instanceof TileEntityBatteryBox) {
TileEntityBatteryBox box = (TileEntityBatteryBox) tile;
ItemStack stack = player.getHeldItem(hand);
if(StackUtil.isValid(stack)){
if(stack.getItem() instanceof ItemBattery && !StackUtil.isValid(box.inv.getStackInSlot(0))){
if (StackUtil.isValid(stack)) {
if (stack.getItem() instanceof ItemBattery && !StackUtil.isValid(box.inv.getStackInSlot(0))) {
box.inv.setStackInSlot(0, stack.copy());
player.setHeldItem(hand, StackUtil.getEmpty());
return true;
}
}
else{
} else {
ItemStack inSlot = box.inv.getStackInSlot(0);
if(StackUtil.isValid(inSlot)){
if (StackUtil.isValid(inSlot)) {
player.setHeldItem(hand, inSlot.copy());
box.inv.setStackInSlot(0, StackUtil.getEmpty());
return true;
@ -75,12 +74,12 @@ public class BlockBatteryBox extends BlockContainerBase{
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
}

View file

@ -26,9 +26,9 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockBioReactor extends BlockContainerBase{
public class BlockBioReactor extends BlockContainerBase {
public BlockBioReactor(String name){
public BlockBioReactor(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
@ -38,14 +38,14 @@ public class BlockBioReactor extends BlockContainerBase{
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta){
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityBioReactor();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
if(world.getTileEntity(pos) instanceof TileEntityBioReactor){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
if (world.getTileEntity(pos) instanceof TileEntityBioReactor) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BIO_REACTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
@ -53,7 +53,7 @@ public class BlockBioReactor extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
}

View file

@ -12,9 +12,9 @@ package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBushBase;
public class BlockBlackLotus extends BlockBushBase{
public class BlockBlackLotus extends BlockBushBase {
public BlockBlackLotus(String name){
public BlockBlackLotus(String name) {
super(name);
}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
@ -33,11 +32,11 @@ import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockBreaker extends BlockContainerBase{
public class BlockBreaker extends BlockContainerBase {
private final boolean isPlacer;
public BlockBreaker(boolean isPlacer, String name){
public BlockBreaker(boolean isPlacer, String name) {
super(Material.ROCK, name);
this.isPlacer = isPlacer;
this.setHarvestLevel("pickaxe", 0);
@ -46,20 +45,17 @@ public class BlockBreaker extends BlockContainerBase{
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return this.isPlacer ? new TileEntityPlacer() : new TileEntityBreaker();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(this.tryToggleRedstone(world, pos, player)){
return true;
}
if(!world.isRemote){
TileEntityBreaker breaker = (TileEntityBreaker)world.getTileEntity(pos);
if(breaker != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (this.tryToggleRedstone(world, pos, player)) { return true; }
if (!world.isRemote) {
TileEntityBreaker breaker = (TileEntityBreaker) world.getTileEntity(pos);
if (breaker != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BREAKER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
@ -68,12 +64,12 @@ public class BlockBreaker extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.UNCOMMON;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
int rotation = EnumFacing.getDirectionFromEntityLiving(pos, player).ordinal();
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
@ -81,27 +77,27 @@ public class BlockBreaker extends BlockContainerBase{
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockDirectional.FACING).getIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockDirectional.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
}
}

View file

@ -26,9 +26,9 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockCanolaPress extends BlockContainerBase{
public class BlockCanolaPress extends BlockContainerBase {
public BlockCanolaPress(String name){
public BlockCanolaPress(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -37,26 +37,26 @@ public class BlockCanolaPress extends BlockContainerBase{
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityCanolaPress();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityCanolaPress press = (TileEntityCanolaPress)world.getTileEntity(pos);
if(press != null){
if(!this.tryUseItemOnTank(player, hand, press.tank)){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float par7, float par8, float par9) {
if (!world.isRemote) {
TileEntityCanolaPress press = (TileEntityCanolaPress) world.getTileEntity(pos);
if (press != null) {
if (!this.tryUseItemOnTank(player, hand, press.tank)) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.CANOLA_PRESS.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
@ -66,7 +66,7 @@ public class BlockCanolaPress extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
}

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.Random;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
@ -25,17 +26,19 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Random;
public class BlockCoalGenerator extends BlockContainerBase {
public class BlockCoalGenerator extends BlockContainerBase{
public BlockCoalGenerator(String name){
public BlockCoalGenerator(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -45,38 +48,38 @@ public class BlockCoalGenerator extends BlockContainerBase{
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityCoalGenerator();
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityCoalGenerator){
if(((TileEntityCoalGenerator)tile).currentBurnTime > 0){
for(int i = 0; i < 5; i++){
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D);
if (tile instanceof TileEntityCoalGenerator) {
if (((TileEntityCoalGenerator) tile).currentBurnTime > 0) {
for (int i = 0; i < 5; i++) {
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) pos.getX() + 0.5F, (double) pos.getY() + 1.0F, (double) pos.getZ() + 0.5F, 0.0D, 0.0D, 0.0D);
}
}
}
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityCoalGenerator press = (TileEntityCoalGenerator)world.getTileEntity(pos);
if(press != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
TileEntityCoalGenerator press = (TileEntityCoalGenerator) world.getTileEntity(pos);
if (press != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.COAL_GENERATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
@ -85,39 +88,39 @@ public class BlockCoalGenerator extends BlockContainerBase{
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockHorizontal.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING)));
}
}

View file

@ -34,11 +34,11 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockCoffeeMachine extends BlockContainerBase{
public class BlockCoffeeMachine extends BlockContainerBase {
private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0625, 0, 0.0625, 1-0.0625, 1-0.0625*2, 1-0.0625);
private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0625, 0, 0.0625, 1 - 0.0625, 1 - 0.0625 * 2, 1 - 0.0625);
public BlockCoffeeMachine(String name){
public BlockCoffeeMachine(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -47,26 +47,26 @@ public class BlockCoffeeMachine extends BlockContainerBase{
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return AABB;
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing f6, float f7, float f8, float f9){
if(!world.isRemote){
TileEntityCoffeeMachine machine = (TileEntityCoffeeMachine)world.getTileEntity(pos);
if(machine != null){
if(!this.tryUseItemOnTank(player, hand, machine.tank)){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing f6, float f7, float f8, float f9) {
if (!world.isRemote) {
TileEntityCoffeeMachine machine = (TileEntityCoffeeMachine) world.getTileEntity(pos);
if (machine != null) {
if (!this.tryUseItemOnTank(player, hand, machine.tank)) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.COFFEE_MACHINE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
@ -75,31 +75,30 @@ public class BlockCoffeeMachine extends BlockContainerBase{
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int meta){
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityCoffeeMachine();
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
int rotation = MathHelper.floor(player.rotationYaw*4.0F/360.0F+0.5D) & 3;
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
int rotation = MathHelper.floor(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
if(rotation == 0){
if (rotation == 0) {
world.setBlockState(pos, this.getStateFromMeta(0), 2);
}
if(rotation == 1){
if (rotation == 1) {
world.setBlockState(pos, this.getStateFromMeta(3), 2);
}
if(rotation == 2){
if (rotation == 2) {
world.setBlockState(pos, this.getStateFromMeta(1), 2);
}
if(rotation == 3){
if (rotation == 3) {
world.setBlockState(pos, this.getStateFromMeta(2), 2);
}
@ -107,27 +106,27 @@ public class BlockCoffeeMachine extends BlockContainerBase{
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockHorizontal.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING)));
}
}

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.Random;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
@ -38,15 +39,13 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import java.util.Random;
public class BlockColoredLamp extends BlockBase{
public class BlockColoredLamp extends BlockBase {
public static final TheColoredLampColors[] ALL_LAMP_TYPES = TheColoredLampColors.values();
public static final PropertyEnum<TheColoredLampColors> TYPE = PropertyEnum.create("type", TheColoredLampColors.class);
public final boolean isOn;
public BlockColoredLamp(boolean isOn, String name){
public BlockColoredLamp(boolean isOn, String name) {
super(Material.REDSTONE_LIGHT, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(0.5F);
@ -55,37 +54,37 @@ public class BlockColoredLamp extends BlockBase{
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int par3){
public Item getItemDropped(IBlockState state, Random rand, int par3) {
return Item.getItemFromBlock(InitBlocks.blockColoredLamp);
}
@Override
public int damageDropped(IBlockState state){
public int damageDropped(IBlockState state) {
return this.getMetaFromState(state);
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
//Turning On
if(hand == EnumHand.MAIN_HAND && stack.isEmpty()){
if (hand == EnumHand.MAIN_HAND && stack.isEmpty()) {
world.setBlockState(pos, (this.isOn ? InitBlocks.blockColoredLamp : InitBlocks.blockColoredLampOn).getDefaultState().withProperty(TYPE, state.getValue(TYPE)), 2);
world.notifyLightSet(pos);
return true;
}
if(StackUtil.isValid(stack)){
if (StackUtil.isValid(stack)) {
//Changing Colors
int[] oreIDs = OreDictionary.getOreIDs(stack);
if(oreIDs.length > 0){
for(int oreID : oreIDs){
if (oreIDs.length > 0) {
for (int oreID : oreIDs) {
String name = OreDictionary.getOreName(oreID);
TheColoredLampColors color = TheColoredLampColors.getColorFromDyeName(name);
if(color != null){
if(this.getMetaFromState(state) != color.ordinal()){
if(!world.isRemote){
if (color != null) {
if (this.getMetaFromState(state) != color.ordinal()) {
if (!world.isRemote) {
world.setBlockState(pos, this.getStateFromMeta(color.ordinal()), 2);
if(!player.capabilities.isCreativeMode){
if (!player.capabilities.isCreativeMode) {
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
@ -100,71 +99,67 @@ public class BlockColoredLamp extends BlockBase{
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list){
for(int j = 0; j < ALL_LAMP_TYPES.length; j++){
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (int j = 0; j < ALL_LAMP_TYPES.length; j++) {
list.add(new ItemStack(this, 1, j));
}
}
@Override
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos){
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) {
return this.isOn ? 15 : 0;
}
@Override
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new TheItemBlock(this);
}
@Override
public void registerRendering(){
for(int i = 0; i < ALL_LAMP_TYPES.length; i++){
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName()+"="+ALL_LAMP_TYPES[i].regName);
public void registerRendering() {
for (int i = 0; i < ALL_LAMP_TYPES.length; i++) {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName() + "=" + ALL_LAMP_TYPES[i].regName);
}
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(TYPE, TheColoredLampColors.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(TYPE).ordinal();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, TYPE);
}
public static class TheItemBlock extends ItemBlockBase{
public static class TheItemBlock extends ItemBlockBase {
public TheItemBlock(Block block){
public TheItemBlock(Block block) {
super(block);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
@Override
public String getItemStackDisplayName(ItemStack stack){
if(stack.getItemDamage() >= ALL_LAMP_TYPES.length){
return StringUtil.BUGGED_ITEM_NAME;
}
if(Util.isClient()) return super.getItemStackDisplayName(stack)+(((BlockColoredLamp)this.block).isOn ? " ("+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".onSuffix.desc")+")" : "");
public String getItemStackDisplayName(ItemStack stack) {
if (stack.getItemDamage() >= ALL_LAMP_TYPES.length) { return StringUtil.BUGGED_ITEM_NAME; }
if (Util.isClient()) return super.getItemStackDisplayName(stack) + (((BlockColoredLamp) this.block).isOn ? " (" + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".onSuffix.desc") + ")" : "");
else return super.getItemStackDisplayName(stack);
}
@Override
public String getTranslationKey(ItemStack stack){
return InitBlocks.blockColoredLamp.getTranslationKey()+"_"+ALL_LAMP_TYPES[stack.getItemDamage()].regName;
public String getTranslationKey(ItemStack stack) {
return InitBlocks.blockColoredLamp.getTranslationKey() + "_" + ALL_LAMP_TYPES[stack.getItemDamage()].regName;
}
}
}

View file

@ -10,6 +10,10 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.Random;
import org.apache.commons.lang3.ArrayUtils;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.gen.WorldGenLushCaves;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
@ -37,15 +41,12 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.ArrayUtils;
import java.util.Random;
public class BlockCrystalCluster extends BlockBase implements IColorProvidingBlock, IColorProvidingItem{
public class BlockCrystalCluster extends BlockBase implements IColorProvidingBlock, IColorProvidingItem {
private final TheCrystals crystal;
public BlockCrystalCluster(String name, TheCrystals crystal){
public BlockCrystalCluster(String name, TheCrystals crystal) {
super(Material.GLASS, name);
this.crystal = crystal;
@ -57,89 +58,89 @@ public class BlockCrystalCluster extends BlockBase implements IColorProvidingBlo
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase base){
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase base) {
return this.getStateFromMeta(side.ordinal());
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockDirectional.FACING).getIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockDirectional.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
}
@Override
@SideOnly(Side.CLIENT)
public IBlockColor getBlockColor(){
public IBlockColor getBlockColor() {
return (state, world, pos, tintIndex) -> BlockCrystalCluster.this.crystal.clusterColor;
}
@Override
public BlockRenderLayer getRenderLayer(){
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.TRANSLUCENT;
}
@Override
@SideOnly(Side.CLIENT)
public IItemColor getItemColor(){
public IItemColor getItemColor() {
return (stack, tintIndex) -> BlockCrystalCluster.this.crystal.clusterColor;
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune){
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return InitItems.itemCrystalShard;
}
@Override
public int damageDropped(IBlockState state){
public int damageDropped(IBlockState state) {
return ArrayUtils.indexOf(WorldGenLushCaves.CRYSTAL_CLUSTERS, this);
}
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player){
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return new ItemStack(this);
}
@Override
public int quantityDropped(Random random){
return random.nextInt(5)+2;
public int quantityDropped(Random random) {
return random.nextInt(5) + 2;
}
@Override
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player){
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
return true;
}
}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
@ -32,9 +31,9 @@ import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockDirectionalBreaker extends BlockContainerBase{
public class BlockDirectionalBreaker extends BlockContainerBase {
public BlockDirectionalBreaker(String name){
public BlockDirectionalBreaker(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -42,20 +41,17 @@ public class BlockDirectionalBreaker extends BlockContainerBase{
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityDirectionalBreaker();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(this.tryToggleRedstone(world, pos, player)){
return true;
}
if(!world.isRemote){
TileEntityDirectionalBreaker breaker = (TileEntityDirectionalBreaker)world.getTileEntity(pos);
if(breaker != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (this.tryToggleRedstone(world, pos, player)) { return true; }
if (!world.isRemote) {
TileEntityDirectionalBreaker breaker = (TileEntityDirectionalBreaker) world.getTileEntity(pos);
if (breaker != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DIRECTIONAL_BREAKER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
@ -64,12 +60,12 @@ public class BlockDirectionalBreaker extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
int rotation = EnumFacing.getDirectionFromEntityLiving(pos, player).ordinal();
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
@ -77,27 +73,27 @@ public class BlockDirectionalBreaker extends BlockContainerBase{
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockDirectional.FACING).getIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockDirectional.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
}
}

View file

@ -62,7 +62,7 @@ public class BlockDisplayStand extends BlockContainerBase {
ItemStack toPut = heldItem.copy();
toPut.setCount(1);
stand.inv.setStackInSlot(0, toPut);
if(!player.capabilities.isCreativeMode) heldItem.shrink(1);
if (!player.capabilities.isCreativeMode) heldItem.shrink(1);
return true;
} else if (ItemUtil.canBeStacked(heldItem, display)) {
int maxTransfer = Math.min(display.getCount(), heldItem.getMaxStackSize() - heldItem.getCount());

View file

@ -31,9 +31,9 @@ import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockDropper extends BlockContainerBase{
public class BlockDropper extends BlockContainerBase {
public BlockDropper(String name){
public BlockDropper(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -41,20 +41,17 @@ public class BlockDropper extends BlockContainerBase{
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityDropper();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(this.tryToggleRedstone(world, pos, player)){
return true;
}
if(!world.isRemote){
TileEntityDropper dropper = (TileEntityDropper)world.getTileEntity(pos);
if(dropper != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (this.tryToggleRedstone(world, pos, player)) { return true; }
if (!world.isRemote) {
TileEntityDropper dropper = (TileEntityDropper) world.getTileEntity(pos);
if (dropper != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DROPPER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
@ -63,12 +60,12 @@ public class BlockDropper extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
int rotation = EnumFacing.getDirectionFromEntityLiving(pos, player).ordinal();
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
@ -76,27 +73,27 @@ public class BlockDropper extends BlockContainerBase{
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockDirectional.FACING).getIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockDirectional.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
}
}

View file

@ -28,9 +28,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockEmpowerer extends BlockContainerBase{
public class BlockEmpowerer extends BlockContainerBase {
public BlockEmpowerer(String name){
public BlockEmpowerer(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
@ -40,33 +40,32 @@ public class BlockEmpowerer extends BlockContainerBase{
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta){
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityEmpowerer();
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return BlockSlabs.AABB_BOTTOM_HALF;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
ItemStack heldItem = player.getHeldItem(hand);
if(!world.isRemote){
TileEntityEmpowerer empowerer = (TileEntityEmpowerer)world.getTileEntity(pos);
if(empowerer != null){
if (!world.isRemote) {
TileEntityEmpowerer empowerer = (TileEntityEmpowerer) world.getTileEntity(pos);
if (empowerer != null) {
ItemStack stackThere = empowerer.inv.getStackInSlot(0);
if(StackUtil.isValid(heldItem)){
if(!StackUtil.isValid(stackThere) && TileEntityEmpowerer.isPossibleInput(heldItem)){
if (StackUtil.isValid(heldItem)) {
if (!StackUtil.isValid(stackThere) && TileEntityEmpowerer.isPossibleInput(heldItem)) {
ItemStack toPut = heldItem.copy();
toPut.setCount(1);
empowerer.inv.setStackInSlot(0, toPut);
if(!player.capabilities.isCreativeMode) heldItem.shrink(1);
if (!player.capabilities.isCreativeMode) heldItem.shrink(1);
return true;
}
else if(ItemUtil.canBeStacked(heldItem, stackThere)){
int maxTransfer = Math.min(stackThere.getCount(), heldItem.getMaxStackSize()-heldItem.getCount());
if(maxTransfer > 0){
} else if (ItemUtil.canBeStacked(heldItem, stackThere)) {
int maxTransfer = Math.min(stackThere.getCount(), heldItem.getMaxStackSize() - heldItem.getCount());
if (maxTransfer > 0) {
player.setHeldItem(hand, StackUtil.grow(heldItem, maxTransfer));
ItemStack newStackThere = stackThere.copy();
newStackThere = StackUtil.shrink(newStackThere, maxTransfer);
@ -74,9 +73,8 @@ public class BlockEmpowerer extends BlockContainerBase{
return true;
}
}
}
else{
if(StackUtil.isValid(stackThere)){
} else {
if (StackUtil.isValid(stackThere)) {
player.setHeldItem(hand, stackThere.copy());
empowerer.inv.setStackInSlot(0, StackUtil.getEmpty());
return true;
@ -84,19 +82,18 @@ public class BlockEmpowerer extends BlockContainerBase{
}
}
return false;
}
else{
} else {
return true;
}
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
}

View file

@ -27,11 +27,11 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockEnergizer extends BlockContainerBase{
public class BlockEnergizer extends BlockContainerBase {
private final boolean isEnergizer;
public BlockEnergizer(boolean isEnergizer, String name){
public BlockEnergizer(boolean isEnergizer, String name) {
super(Material.ROCK, name);
this.isEnergizer = isEnergizer;
this.setHarvestLevel("pickaxe", 0);
@ -40,24 +40,22 @@ public class BlockEnergizer extends BlockContainerBase{
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return this.isEnergizer ? new TileEntityEnergizer() : new TileEntityEnervator();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
if(this.isEnergizer){
TileEntityEnergizer energizer = (TileEntityEnergizer)world.getTileEntity(pos);
if(energizer != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
if (this.isEnergizer) {
TileEntityEnergizer energizer = (TileEntityEnergizer) world.getTileEntity(pos);
if (energizer != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.ENERGIZER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
else{
TileEntityEnervator energizer = (TileEntityEnervator)world.getTileEntity(pos);
if(energizer != null){
} else {
TileEntityEnervator energizer = (TileEntityEnervator) world.getTileEntity(pos);
if (energizer != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.ENERVATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
@ -67,7 +65,7 @@ public class BlockEnergizer extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
}

View file

@ -31,9 +31,9 @@ import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockFarmer extends BlockContainerBase{
public class BlockFarmer extends BlockContainerBase {
public BlockFarmer(String name){
public BlockFarmer(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -41,17 +41,16 @@ public class BlockFarmer extends BlockContainerBase{
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityFarmer();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityFarmer farmer = (TileEntityFarmer)world.getTileEntity(pos);
if(farmer != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
TileEntityFarmer farmer = (TileEntityFarmer) world.getTileEntity(pos);
if (farmer != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FARMER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
@ -60,39 +59,39 @@ public class BlockFarmer extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockHorizontal.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING)));
}
}

View file

@ -26,9 +26,9 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockFeeder extends BlockContainerBase{
public class BlockFeeder extends BlockContainerBase {
public BlockFeeder(String name){
public BlockFeeder(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(0.5F);
@ -36,17 +36,16 @@ public class BlockFeeder extends BlockContainerBase{
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityFeeder();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityFeeder feeder = (TileEntityFeeder)world.getTileEntity(pos);
if(feeder != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
TileEntityFeeder feeder = (TileEntityFeeder) world.getTileEntity(pos);
if (feeder != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FEEDER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
@ -55,7 +54,7 @@ public class BlockFeeder extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.UNCOMMON;
}
}

View file

@ -26,9 +26,9 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockFermentingBarrel extends BlockContainerBase{
public class BlockFermentingBarrel extends BlockContainerBase {
public BlockFermentingBarrel(String name){
public BlockFermentingBarrel(String name) {
super(Material.WOOD, name);
this.setHarvestLevel("axe", 0);
this.setHardness(0.5F);
@ -37,26 +37,26 @@ public class BlockFermentingBarrel extends BlockContainerBase{
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityFermentingBarrel();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityFermentingBarrel press = (TileEntityFermentingBarrel)world.getTileEntity(pos);
if(press != null){
if(!this.tryUseItemOnTank(player, hand, press.canolaTank) && !this.tryUseItemOnTank(player, hand, press.oilTank)){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
TileEntityFermentingBarrel press = (TileEntityFermentingBarrel) world.getTileEntity(pos);
if (press != null) {
if (!this.tryUseItemOnTank(player, hand, press.canolaTank) && !this.tryUseItemOnTank(player, hand, press.oilTank)) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FERMENTING_BARREL.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
@ -66,7 +66,7 @@ public class BlockFermentingBarrel extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
@ -27,9 +26,9 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockFireworkBox extends BlockContainerBase{
public class BlockFireworkBox extends BlockContainerBase {
public BlockFireworkBox(String name){
public BlockFireworkBox(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -38,13 +37,12 @@ public class BlockFireworkBox extends BlockContainerBase{
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(this.tryToggleRedstone(world, pos, player)){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (this.tryToggleRedstone(world, pos, player)) {
return true;
}
else if(!world.isRemote){
TileEntityFireworkBox grinder = (TileEntityFireworkBox)world.getTileEntity(pos);
if(grinder != null){
} else if (!world.isRemote) {
TileEntityFireworkBox grinder = (TileEntityFireworkBox) world.getTileEntity(pos);
if (grinder != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FIREWORK_BOX.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
@ -52,12 +50,12 @@ public class BlockFireworkBox extends BlockContainerBase{
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityFireworkBox();
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
}

View file

@ -23,11 +23,11 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockFishingNet extends BlockContainerBase{
public class BlockFishingNet extends BlockContainerBase {
private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 1, 0.0625, 1);
public BlockFishingNet(String name){
public BlockFishingNet(String name) {
super(Material.WOOD, name);
this.setHarvestLevel("axe", 0);
this.setHardness(0.5F);
@ -36,28 +36,27 @@ public class BlockFishingNet extends BlockContainerBase{
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return AABB;
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityFishingNet();
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
@ -33,11 +32,11 @@ import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockFluidCollector extends BlockContainerBase{
public class BlockFluidCollector extends BlockContainerBase {
private final boolean isPlacer;
public BlockFluidCollector(boolean isPlacer, String name){
public BlockFluidCollector(boolean isPlacer, String name) {
super(Material.ROCK, name);
this.isPlacer = isPlacer;
this.setHarvestLevel("pickaxe", 0);
@ -46,21 +45,18 @@ public class BlockFluidCollector extends BlockContainerBase{
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return this.isPlacer ? new TileEntityFluidPlacer() : new TileEntityFluidCollector();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(this.tryToggleRedstone(world, pos, player)){
return true;
}
if(!world.isRemote){
TileEntityFluidCollector collector = (TileEntityFluidCollector)world.getTileEntity(pos);
if(collector != null){
if(!this.tryUseItemOnTank(player, hand, collector.tank)){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (this.tryToggleRedstone(world, pos, player)) { return true; }
if (!world.isRemote) {
TileEntityFluidCollector collector = (TileEntityFluidCollector) world.getTileEntity(pos);
if (collector != null) {
if (!this.tryUseItemOnTank(player, hand, collector.tank)) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FLUID_COLLECTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
@ -70,12 +66,12 @@ public class BlockFluidCollector extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
int rotation = EnumFacing.getDirectionFromEntityLiving(pos, player).ordinal();
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
@ -83,27 +79,27 @@ public class BlockFluidCollector extends BlockContainerBase{
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockDirectional.FACING).getIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockDirectional.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
}
}

View file

@ -10,6 +10,9 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.List;
import java.util.Random;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
@ -29,7 +32,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockAccess;
@ -37,14 +44,11 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
import java.util.Random;
public class BlockFurnaceDouble extends BlockContainerBase{
public class BlockFurnaceDouble extends BlockContainerBase {
public static final PropertyBool IS_ON = PropertyBool.create("on");
public BlockFurnaceDouble(String name){
public BlockFurnaceDouble(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -53,27 +57,26 @@ public class BlockFurnaceDouble extends BlockContainerBase{
this.setTickRandomly(true);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityFurnaceDouble();
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){
if(state.getValue(IS_ON)){
for(int i = 0; i < 5; i++){
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D);
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
if (state.getValue(IS_ON)) {
for (int i = 0; i < 5; i++) {
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) pos.getX() + 0.5F, (double) pos.getY() + 1.0F, (double) pos.getZ() + 0.5F, 0.0D, 0.0D, 0.0D);
}
}
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityFurnaceDouble furnace = (TileEntityFurnaceDouble)world.getTileEntity(pos);
if(furnace != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
TileEntityFurnaceDouble furnace = (TileEntityFurnaceDouble) world.getTileEntity(pos);
if (furnace != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FURNACE_DOUBLE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
@ -82,64 +85,64 @@ public class BlockFurnaceDouble extends BlockContainerBase{
}
@Override
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos){
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) {
return state.getValue(IS_ON) ? 12 : 0;
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.UNCOMMON;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
boolean isOn = meta >= 4;
EnumFacing facing = EnumFacing.byHorizontalIndex(isOn ? meta-4 : meta);
EnumFacing facing = EnumFacing.byHorizontalIndex(isOn ? meta - 4 : meta);
return this.getDefaultState().withProperty(BlockHorizontal.FACING, facing).withProperty(IS_ON, isOn);
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
int meta = state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
return state.getValue(IS_ON) ? meta+4 : meta;
return state.getValue(IS_ON) ? meta + 4 : meta;
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockHorizontal.FACING, IS_ON);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING)));
}
@Override
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new TheItemBlock(this);
}
public static class TheItemBlock extends ItemBlockBase{
public static class TheItemBlock extends ItemBlockBase {
public TheItemBlock(Block block){
public TheItemBlock(Block block) {
super(block);
}
@Override
public void addInformation(ItemStack stack, World playerIn, List<String> tooltip, ITooltipFlag advanced){
tooltip.add(TextFormatting.ITALIC+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".previouslyDoubleFurnace"));
public void addInformation(ItemStack stack, World playerIn, List<String> tooltip, ITooltipFlag advanced) {
tooltip.add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".previouslyDoubleFurnace"));
}
}
}

View file

@ -23,11 +23,11 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockFurnaceSolar extends BlockContainerBase{
public class BlockFurnaceSolar extends BlockContainerBase {
private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 1, 6*0.0625, 1);
private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 1, 6 * 0.0625, 1);
public BlockFurnaceSolar(String name){
public BlockFurnaceSolar(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -36,28 +36,27 @@ public class BlockFurnaceSolar extends BlockContainerBase{
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return AABB;
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityFurnaceSolar();
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.UNCOMMON;
}
}

View file

@ -16,13 +16,13 @@ import net.minecraft.block.material.Material;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
public class BlockGeneric extends BlockBase{
public class BlockGeneric extends BlockBase {
public BlockGeneric(String name){
public BlockGeneric(String name) {
this(name, Material.ROCK, SoundType.STONE, 1.5F, 10.0F, "pickaxe", 0);
}
public BlockGeneric(String name, Material material, SoundType sound, float hardness, float resistance, String harvestTool, int harvestLevel){
public BlockGeneric(String name, Material material, SoundType sound, float hardness, float resistance, String harvestTool, int harvestLevel) {
super(material, name);
this.setHarvestLevel(harvestTool, harvestLevel);
this.setHardness(hardness);
@ -31,7 +31,7 @@ public class BlockGeneric extends BlockBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.COMMON;
}
}

View file

@ -45,11 +45,11 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandlerModifiable;
public class BlockGiantChest extends BlockContainerBase{
public class BlockGiantChest extends BlockContainerBase {
public final int type;
public BlockGiantChest(String name, int type){
public BlockGiantChest(String name, int type) {
super(Material.WOOD, name);
this.type = type;
@ -61,8 +61,8 @@ public class BlockGiantChest extends BlockContainerBase{
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
switch(this.type){
public TileEntity createNewTileEntity(World world, int par2) {
switch (this.type) {
case 1:
return new TileEntityGiantChestMedium();
case 2:
@ -73,20 +73,20 @@ public class BlockGiantChest extends BlockContainerBase{
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityGiantChest chest = (TileEntityGiantChest)world.getTileEntity(pos);
if(chest != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
TileEntityGiantChest chest = (TileEntityGiantChest) world.getTileEntity(pos);
if (chest != null) {
chest.fillWithLoot(player);
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.GIANT_CHEST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
@ -96,21 +96,21 @@ public class BlockGiantChest extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack){
if(stack.getTagCompound() != null){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack) {
if (stack.getTagCompound() != null) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityGiantChest){
if (tile instanceof TileEntityGiantChest) {
NBTTagList list = stack.getTagCompound().getTagList("Items", 10);
IItemHandlerModifiable inv = ((TileEntityGiantChest)tile).inv;
IItemHandlerModifiable inv = ((TileEntityGiantChest) tile).inv;
for(int i = 0; i < list.tagCount(); i++){
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound compound = list.getCompoundTagAt(i);
if(compound != null && compound.hasKey("id")){
if (compound != null && compound.hasKey("id")) {
inv.setStackInSlot(i, new ItemStack(list.getCompoundTagAt(i)));
}
}
@ -120,31 +120,30 @@ public class BlockGiantChest extends BlockContainerBase{
super.onBlockPlacedBy(world, pos, state, entity, stack);
}
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune){
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
super.getDrops(drops, world, pos, state, fortune);
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityGiantChest){
ItemStackHandlerAA slots = ((TileEntityGiantChest)tile).inv;
if (tile instanceof TileEntityGiantChest) {
ItemStackHandlerAA slots = ((TileEntityGiantChest) tile).inv;
int place = ItemUtil.getPlaceAt(slots.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
if(place >= 0){
if (place >= 0) {
NBTTagList list = new NBTTagList();
for(int i = 0; i < slots.getSlots(); i++){
for (int i = 0; i < slots.getSlots(); i++) {
//Destroy the keeper
if(i != place){
if (i != place) {
NBTTagCompound compound = new NBTTagCompound();
if(StackUtil.isValid(slots.getStackInSlot(i))){
if (StackUtil.isValid(slots.getStackInSlot(i))) {
slots.getStackInSlot(i).writeToNBT(compound);
}
list.appendTag(compound);
}
}
if(list.tagCount() > 0){
if (list.tagCount() > 0) {
ItemStack stackInQuestion = drops.get(0);
if(StackUtil.isValid(stackInQuestion)){
if(stackInQuestion.getTagCompound() == null){
if (StackUtil.isValid(stackInQuestion)) {
if (stackInQuestion.getTagCompound() == null) {
stackInQuestion.setTagCompound(new NBTTagCompound());
}
stackInQuestion.getTagCompound().setTag("Items", list);
@ -161,29 +160,28 @@ public class BlockGiantChest extends BlockContainerBase{
}
@Override
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new TheItemBlock(this);
}
public static class TheItemBlock extends ItemBlockBase{
public static class TheItemBlock extends ItemBlockBase {
public TheItemBlock(Block block){
public TheItemBlock(Block block) {
super(block);
}
@Override
public void addInformation(ItemStack stack, World playerIn, List<String> tooltip, ITooltipFlag advanced){
int type = this.block instanceof BlockGiantChest ? ((BlockGiantChest)this.block).type : -1;
if(type == 2){
tooltip.add(TextFormatting.ITALIC+StringUtil.localize("container."+ActuallyAdditions.MODID+".giantChestLarge.desc"));
}
else if(type == 0){
tooltip.add(TextFormatting.ITALIC+StringUtil.localize("container."+ActuallyAdditions.MODID+".giantChest.desc"));
public void addInformation(ItemStack stack, World playerIn, List<String> tooltip, ITooltipFlag advanced) {
int type = this.block instanceof BlockGiantChest ? ((BlockGiantChest) this.block).type : -1;
if (type == 2) {
tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container." + ActuallyAdditions.MODID + ".giantChestLarge.desc"));
} else if (type == 0) {
tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container." + ActuallyAdditions.MODID + ".giantChest.desc"));
}
}
@Override
public NBTTagCompound getNBTShareTag(ItemStack stack){
public NBTTagCompound getNBTShareTag(ItemStack stack) {
return null;
}
}

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.Random;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
@ -32,13 +34,11 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Random;
public class BlockGrinder extends BlockContainerBase{
public class BlockGrinder extends BlockContainerBase {
private final boolean isDouble;
public BlockGrinder(boolean isDouble, String name){
public BlockGrinder(boolean isDouble, String name) {
super(Material.ROCK, name);
this.isDouble = isDouble;
this.setHarvestLevel("pickaxe", 0);
@ -49,28 +49,28 @@ public class BlockGrinder extends BlockContainerBase{
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return this.isDouble ? new TileEntityGrinderDouble() : new TileEntityGrinder();
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){
if(state.getValue(BlockFurnaceDouble.IS_ON)){
for(int i = 0; i < 5; i++){
double xRand = rand.nextDouble()/0.75D-0.5D;
double zRand = rand.nextDouble()/0.75D-0.5D;
world.spawnParticle(EnumParticleTypes.CRIT, (double)pos.getX()+0.4F, (double)pos.getY()+0.8F, (double)pos.getZ()+0.4F, xRand, 0.5D, zRand);
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
if (state.getValue(BlockFurnaceDouble.IS_ON)) {
for (int i = 0; i < 5; i++) {
double xRand = rand.nextDouble() / 0.75D - 0.5D;
double zRand = rand.nextDouble() / 0.75D - 0.5D;
world.spawnParticle(EnumParticleTypes.CRIT, (double) pos.getX() + 0.4F, (double) pos.getY() + 0.8F, (double) pos.getZ() + 0.4F, xRand, 0.5D, zRand);
}
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D);
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) pos.getX() + 0.5F, (double) pos.getY() + 1.0F, (double) pos.getZ() + 0.5F, 0.0D, 0.0D, 0.0D);
}
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityGrinder grinder = (TileEntityGrinder)world.getTileEntity(pos);
if(grinder != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
TileEntityGrinder grinder = (TileEntityGrinder) world.getTileEntity(pos);
if (grinder != null) {
player.openGui(ActuallyAdditions.INSTANCE, this.isDouble ? GuiHandler.GuiTypes.GRINDER_DOUBLE.ordinal() : GuiHandler.GuiTypes.GRINDER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
@ -79,34 +79,33 @@ public class BlockGrinder extends BlockContainerBase{
}
@Override
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos){
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) {
return this.getMetaFromState(state) == 1 ? 12 : 0;
}
@Override
public int damageDropped(IBlockState state){
public int damageDropped(IBlockState state) {
return 0;
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
boolean isOn = meta == 1;
return this.getDefaultState().withProperty(BlockFurnaceDouble.IS_ON, isOn);
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockFurnaceDouble.IS_ON) ? 1 : 0;
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockFurnaceDouble.IS_ON);
}
}

View file

@ -19,9 +19,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockHeatCollector extends BlockContainerBase{
public class BlockHeatCollector extends BlockContainerBase {
public BlockHeatCollector(String name){
public BlockHeatCollector(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(2.5F);
@ -29,14 +29,13 @@ public class BlockHeatCollector extends BlockContainerBase{
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityHeatCollector();
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.UNCOMMON;
}
}

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.Random;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
@ -32,15 +33,13 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.Random;
public class BlockInputter extends BlockContainerBase{
public class BlockInputter extends BlockContainerBase {
public static final int NAME_FLAVOR_AMOUNTS = 15;
public final boolean isAdvanced;
public BlockInputter(boolean isAdvanced, String name){
public BlockInputter(boolean isAdvanced, String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -50,17 +49,16 @@ public class BlockInputter extends BlockContainerBase{
this.isAdvanced = isAdvanced;
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return this.isAdvanced ? new TileEntityInputterAdvanced() : new TileEntityInputter();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityInputter inputter = (TileEntityInputter)world.getTileEntity(pos);
if(inputter != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
TileEntityInputter inputter = (TileEntityInputter) world.getTileEntity(pos);
if (inputter != null) {
player.openGui(ActuallyAdditions.INSTANCE, this.isAdvanced ? GuiHandler.GuiTypes.INPUTTER_ADVANCED.ordinal() : GuiHandler.GuiTypes.INPUTTER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
@ -69,52 +67,49 @@ public class BlockInputter extends BlockContainerBase{
}
@Override
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new TheItemBlock(this);
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
public static class TheItemBlock extends ItemBlockBase{
public static class TheItemBlock extends ItemBlockBase {
private final Random rand = new Random();
private long lastSysTime;
private int toPick;
public TheItemBlock(Block block){
public TheItemBlock(Block block) {
super(block);
this.setHasSubtypes(false);
this.setMaxDamage(0);
}
@Override
public String getTranslationKey(ItemStack stack){
public String getTranslationKey(ItemStack stack) {
return this.getTranslationKey();
}
@Override
public int getMetadata(int damage){
public int getMetadata(int damage) {
return damage;
}
@Override
public String getItemStackDisplayName(ItemStack stack){
if(Util.isClient()) {
public String getItemStackDisplayName(ItemStack stack) {
if (Util.isClient()) {
long sysTime = System.currentTimeMillis();
if(this.lastSysTime+5000 < sysTime){
if (this.lastSysTime + 5000 < sysTime) {
this.lastSysTime = sysTime;
this.toPick = this.rand.nextInt(NAME_FLAVOR_AMOUNTS)+1;
this.toPick = this.rand.nextInt(NAME_FLAVOR_AMOUNTS) + 1;
}
return StringUtil.localize(this.getTranslationKey()+".name")+" ("+StringUtil.localize("tile."+ActuallyAdditions.MODID+".block_inputter.add."+this.toPick+".name")+")";
}
else return super.getItemStackDisplayName(stack);
return StringUtil.localize(this.getTranslationKey() + ".name") + " (" + StringUtil.localize("tile." + ActuallyAdditions.MODID + ".block_inputter.add." + this.toPick + ".name") + ")";
} else return super.getItemStackDisplayName(stack);
}
}
}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
@ -28,9 +27,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockItemRepairer extends BlockContainerBase{
public class BlockItemRepairer extends BlockContainerBase {
public BlockItemRepairer(String name){
public BlockItemRepairer(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(20.0F);
@ -39,17 +38,16 @@ public class BlockItemRepairer extends BlockContainerBase{
this.setTickRandomly(true);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityItemRepairer();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityItemRepairer repairer = (TileEntityItemRepairer)world.getTileEntity(pos);
if(repairer != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
TileEntityItemRepairer repairer = (TileEntityItemRepairer) world.getTileEntity(pos);
if (repairer != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.REPAIRER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
@ -58,12 +56,12 @@ public class BlockItemRepairer extends BlockContainerBase{
}
@Override
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos){
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) {
return this.getMetaFromState(state) == 1 ? 12 : 0;
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
}

View file

@ -19,9 +19,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockItemViewer extends BlockContainerBase{
public class BlockItemViewer extends BlockContainerBase {
public BlockItemViewer(String name){
public BlockItemViewer(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -30,12 +30,12 @@ public class BlockItemViewer extends BlockContainerBase{
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta){
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityItemViewer();
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
}

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewerHopping;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
@ -28,10 +30,8 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
//Most of this is just copied from BlockHopper, no credit taken. Or clue what it is.
public class BlockItemViewerHopping extends BlockItemViewer{
public class BlockItemViewerHopping extends BlockItemViewer {
public static final PropertyDirection FACING = PropertyDirection.create("facing", facing -> facing != EnumFacing.UP);
@ -41,18 +41,18 @@ public class BlockItemViewerHopping extends BlockItemViewer{
private static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
private static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D);
public BlockItemViewerHopping(String name){
public BlockItemViewerHopping(String name) {
super(name);
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return FULL_BLOCK_AABB;
}
@Override
@Deprecated
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean someBool){
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean someBool) {
addCollisionBoxToList(pos, entityBox, collidingBoxes, BASE_AABB);
addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB);
addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB);
@ -61,64 +61,64 @@ public class BlockItemViewerHopping extends BlockItemViewer{
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta){
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityItemViewerHopping();
}
@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer){
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
EnumFacing opp = facing.getOpposite();
return this.getDefaultState().withProperty(FACING, opp == EnumFacing.UP ? EnumFacing.DOWN : opp);
}
@Override //was isFullyOpaque, not sure if correct change.
public boolean isNormalCube(IBlockState state){
public boolean isNormalCube(IBlockState state) {
return true;
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side){
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
return true;
}
@Override
public BlockRenderLayer getRenderLayer(){
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT_MIPPED;
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(FACING, EnumFacing.byIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(FACING).getIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(FACING, rot.rotate(state.getValue(FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(FACING)));
}
}

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.ArrayList;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
@ -28,12 +30,9 @@ import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class BlockLampPowerer extends BlockBase {
public class BlockLampPowerer extends BlockBase{
public BlockLampPowerer(String name){
public BlockLampPowerer(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -42,43 +41,42 @@ public class BlockLampPowerer extends BlockBase{
}
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos otherPos){
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos otherPos) {
this.updateLamp(worldIn, pos);
}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state){
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
this.updateLamp(world, pos);
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
int rotation = EnumFacing.getDirectionFromEntityLiving(pos, player).ordinal();
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
}
private void updateLamp(World world, BlockPos pos){
if(!world.isRemote){
private void updateLamp(World world, BlockPos pos) {
if (!world.isRemote) {
IBlockState state = world.getBlockState(pos);
BlockPos coords = pos.offset(WorldUtil.getDirectionByPistonRotation(state));
this.updateLampsAtPos(world, coords, world.getRedstonePowerFromNeighbors(pos) > 0, new ArrayList<BlockPos>());
}
}
private void updateLampsAtPos(World world, BlockPos pos, boolean powered, List<BlockPos> updatedAlready){
private void updateLampsAtPos(World world, BlockPos pos, boolean powered, List<BlockPos> updatedAlready) {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if(block instanceof BlockColoredLamp){
if (block instanceof BlockColoredLamp) {
boolean isOn = ((BlockColoredLamp) block).isOn;
if(powered){
if(!isOn){
if (powered) {
if (!isOn) {
world.setBlockState(pos, InitBlocks.blockColoredLampOn.getDefaultState().withProperty(BlockColoredLamp.TYPE, state.getValue(BlockColoredLamp.TYPE)), 2);
}
}
else{
if(isOn){
} else {
if (isOn) {
world.setBlockState(pos, InitBlocks.blockColoredLamp.getDefaultState().withProperty(BlockColoredLamp.TYPE, state.getValue(BlockColoredLamp.TYPE)), 2);
}
}
@ -87,10 +85,10 @@ public class BlockLampPowerer extends BlockBase{
}
}
private void updateSurrounding(World world, BlockPos pos, boolean powered, List<BlockPos> updatedAlready){
for(EnumFacing side : EnumFacing.values()){
private void updateSurrounding(World world, BlockPos pos, boolean powered, List<BlockPos> updatedAlready) {
for (EnumFacing side : EnumFacing.values()) {
BlockPos offset = pos.offset(side);
if(!updatedAlready.contains(offset)){
if (!updatedAlready.contains(offset)) {
updatedAlready.add(pos);
this.updateLampsAtPos(world, offset, powered, updatedAlready);
}
@ -98,32 +96,32 @@ public class BlockLampPowerer extends BlockBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockDirectional.FACING).getIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockDirectional.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
}
}

View file

@ -19,7 +19,13 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.ItemEngineerGoggles;
import de.ellpeck.actuallyadditions.mod.items.ItemLaserRelayUpgrade;
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
import de.ellpeck.actuallyadditions.mod.tile.*;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyAdvanced;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyExtreme;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayFluids;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItem;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemWhitelist;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.BlockDirectional;
@ -52,20 +58,20 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay {
//This took way too much fiddling around. I'm not good with numbers.
private static final float F = 1/16F;
private static final AxisAlignedBB AABB_UP = new AxisAlignedBB(2*F, 0, 2*F, 1-2*F, 10*F, 1-2*F);
private static final AxisAlignedBB AABB_DOWN = new AxisAlignedBB(2*F, 6*F, 2*F, 1-2*F, 1, 1-2*F);
private static final AxisAlignedBB AABB_NORTH = new AxisAlignedBB(2*F, 2*F, 6*F, 1-2*F, 1-2*F, 1);
private static final AxisAlignedBB AABB_EAST = new AxisAlignedBB(0, 2*F, 2*F, 1-6*F, 1-2*F, 1-2*F);
private static final AxisAlignedBB AABB_SOUTH = new AxisAlignedBB(2*F, 2*F, 0, 1-2*F, 1-2*F, 1-6*F);
private static final AxisAlignedBB AABB_WEST = new AxisAlignedBB(6*F, 2*F, 2*F, 1, 1-2*F, 1-2*F);
private static final float F = 1 / 16F;
private static final AxisAlignedBB AABB_UP = new AxisAlignedBB(2 * F, 0, 2 * F, 1 - 2 * F, 10 * F, 1 - 2 * F);
private static final AxisAlignedBB AABB_DOWN = new AxisAlignedBB(2 * F, 6 * F, 2 * F, 1 - 2 * F, 1, 1 - 2 * F);
private static final AxisAlignedBB AABB_NORTH = new AxisAlignedBB(2 * F, 2 * F, 6 * F, 1 - 2 * F, 1 - 2 * F, 1);
private static final AxisAlignedBB AABB_EAST = new AxisAlignedBB(0, 2 * F, 2 * F, 1 - 6 * F, 1 - 2 * F, 1 - 2 * F);
private static final AxisAlignedBB AABB_SOUTH = new AxisAlignedBB(2 * F, 2 * F, 0, 1 - 2 * F, 1 - 2 * F, 1 - 6 * F);
private static final AxisAlignedBB AABB_WEST = new AxisAlignedBB(6 * F, 2 * F, 2 * F, 1, 1 - 2 * F, 1 - 2 * F);
private final Type type;
public BlockLaserRelay(String name, Type type){
public BlockLaserRelay(String name, Type type) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -74,22 +80,22 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
this.type = type;
if(this.type.ordinal() == 0){
if (this.type.ordinal() == 0) {
MinecraftForge.EVENT_BUS.register(this);
}
}
@SubscribeEvent
public void onBlockRightClick(PlayerInteractEvent.RightClickBlock event){
public void onBlockRightClick(PlayerInteractEvent.RightClickBlock event) {
EntityPlayer player = event.getEntityPlayer();
World world = event.getWorld();
ItemStack stack = event.getItemStack();
BlockPos pos = event.getPos();
if(player != null && world != null && StackUtil.isValid(stack) && pos != null){
if (player != null && world != null && StackUtil.isValid(stack) && pos != null) {
IBlockState state = event.getWorld().getBlockState(pos);
if(state != null && state.getBlock() instanceof BlockLaserRelay){
if(player.isSneaking()){
if (state != null && state.getBlock() instanceof BlockLaserRelay) {
if (player.isSneaking()) {
event.setUseBlock(Event.Result.ALLOW);
}
}
@ -97,8 +103,8 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
switch(this.getMetaFromState(state)){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
switch (this.getMetaFromState(state)) {
case 1:
return AABB_UP;
case 2:
@ -115,67 +121,66 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase base){
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase base) {
return this.getStateFromMeta(side.ordinal());
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockDirectional.FACING).getIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockDirectional.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
ItemStack stack = player.getHeldItem(hand);
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityLaserRelay){
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
if (tile instanceof TileEntityLaserRelay) {
TileEntityLaserRelay relay = (TileEntityLaserRelay) tile;
if(StackUtil.isValid(stack)){
if(stack.getItem() instanceof ItemLaserWrench){
if (StackUtil.isValid(stack)) {
if (stack.getItem() instanceof ItemLaserWrench) {
return false;
}
else if(stack.getItem() == ConfigValues.itemCompassConfigurator){
if(!world.isRemote){
} else if (stack.getItem() == ConfigValues.itemCompassConfigurator) {
if (!world.isRemote) {
relay.onCompassAction(player);
Network network = relay.getNetwork();
if(network != null){
if (network != null) {
network.changeAmount++;
}
@ -184,12 +189,11 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
}
return true;
}
else if(stack.getItem() instanceof ItemLaserRelayUpgrade){
} else if (stack.getItem() instanceof ItemLaserRelayUpgrade) {
ItemStack inRelay = relay.inv.getStackInSlot(0);
if(!StackUtil.isValid(inRelay)){
if(!world.isRemote){
if(!player.isCreative()){
if (!StackUtil.isValid(inRelay)) {
if (!world.isRemote) {
if (!player.isCreative()) {
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
}
@ -203,13 +207,13 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
}
}
if(player.isSneaking()){
if (player.isSneaking()) {
ItemStack inRelay = relay.inv.getStackInSlot(0).copy();
if(StackUtil.isValid(inRelay)){
if(!world.isRemote){
if (StackUtil.isValid(inRelay)) {
if (!world.isRemote) {
relay.inv.setStackInSlot(0, StackUtil.getEmpty());
if(!player.inventory.addItemStackToInventory(inRelay)){
if (!player.inventory.addItemStackToInventory(inRelay)) {
player.entityDropItem(inRelay, 0);
}
}
@ -217,8 +221,8 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
}
}
if(relay instanceof TileEntityLaserRelayItemWhitelist){
if(!world.isRemote){
if (relay instanceof TileEntityLaserRelayItemWhitelist) {
if (!world.isRemote) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.LASER_RELAY_ITEM_WHITELIST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
@ -228,8 +232,8 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
}
@Override
public TileEntity createNewTileEntity(World world, int i){
switch(this.type){
public TileEntity createNewTileEntity(World world, int i) {
switch (this.type) {
case ITEM:
return new TileEntityLaserRelayItem();
case ITEM_WHITELIST:
@ -247,28 +251,27 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
@Override
@SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
if(posHit != null && posHit.getBlockPos() != null && minecraft.world != null){
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) {
if (posHit != null && posHit.getBlockPos() != null && minecraft.world != null) {
boolean wearing = ItemEngineerGoggles.isWearing(player);
if(wearing || StackUtil.isValid(stack)){
if (wearing || StackUtil.isValid(stack)) {
boolean compass = stack.getItem() == ConfigValues.itemCompassConfigurator;
if(wearing || compass || stack.getItem() instanceof ItemLaserWrench){
if (wearing || compass || stack.getItem() instanceof ItemLaserWrench) {
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
if(tile instanceof TileEntityLaserRelay){
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
if (tile instanceof TileEntityLaserRelay) {
TileEntityLaserRelay relay = (TileEntityLaserRelay) tile;
String strg = relay.getExtraDisplayString();
minecraft.fontRenderer.drawStringWithShadow(strg, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRenderer.drawStringWithShadow(strg, resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 5, StringUtil.DECIMAL_COLOR_WHITE);
String expl;
if(compass){
if (compass) {
expl = relay.getCompassDisplayString();
}
else{
expl = TextFormatting.GRAY.toString()+TextFormatting.ITALIC+StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".laserRelay.mode.noCompasss", StringUtil.localize(ConfigValues.itemCompassConfigurator.getTranslationKey()+".name"));
} else {
expl = TextFormatting.GRAY.toString() + TextFormatting.ITALIC + StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".laserRelay.mode.noCompasss", StringUtil.localize(ConfigValues.itemCompassConfigurator.getTranslationKey() + ".name"));
}
StringUtil.drawSplitString(minecraft.fontRenderer, expl, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+15, Integer.MAX_VALUE, StringUtil.DECIMAL_COLOR_WHITE, true);
StringUtil.drawSplitString(minecraft.fontRenderer, expl, resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 15, Integer.MAX_VALUE, StringUtil.DECIMAL_COLOR_WHITE, true);
}
}
}
@ -276,7 +279,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state){
public void breakBlock(World world, BlockPos pos, IBlockState state) {
super.breakBlock(world, pos, state);
ActuallyAdditionsAPI.connectionHandler.removeRelayFromNetwork(pos, world);
@ -287,7 +290,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
return BlockFaceShape.UNDEFINED;
}
public enum Type{
public enum Type {
ENERGY_BASIC,
ENERGY_ADVANCED,
ENERGY_EXTREME,

View file

@ -27,9 +27,9 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockLavaFactoryController extends BlockContainerBase implements IHudDisplay{
public class BlockLavaFactoryController extends BlockContainerBase implements IHudDisplay {
public BlockLavaFactoryController(String name){
public BlockLavaFactoryController(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(4.5F);
@ -37,28 +37,26 @@ public class BlockLavaFactoryController extends BlockContainerBase implements IH
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityLavaFactoryController();
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Override
@SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController)minecraft.world.getTileEntity(posHit.getBlockPos());
if(factory != null){
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) {
TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController) minecraft.world.getTileEntity(posHit.getBlockPos());
if (factory != null) {
int state = factory.isMultiblock();
if(state == TileEntityLavaFactoryController.NOT_MULTI){
StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".factory.notPart.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
}
else if(state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA){
StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".factory.works.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
if (state == TileEntityLavaFactoryController.NOT_MULTI) {
StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".factory.notPart.desc"), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 5, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
} else if (state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA) {
StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".factory.works.desc"), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 5, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
}
}
}

View file

@ -19,9 +19,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockLeafGenerator extends BlockContainerBase{
public class BlockLeafGenerator extends BlockContainerBase {
public BlockLeafGenerator(String name){
public BlockLeafGenerator(String name) {
super(Material.IRON, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(5.0F);
@ -29,14 +29,13 @@ public class BlockLeafGenerator extends BlockContainerBase{
this.setSoundType(SoundType.METAL);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityLeafGenerator();
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
@ -33,9 +32,9 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockMiner extends BlockContainerBase implements IHudDisplay{
public class BlockMiner extends BlockContainerBase implements IHudDisplay {
public BlockMiner(String name){
public BlockMiner(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(8F);
@ -44,15 +43,15 @@ public class BlockMiner extends BlockContainerBase implements IHudDisplay{
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityMiner){
if (tile instanceof TileEntityMiner) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.MINER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
@ -60,24 +59,23 @@ public class BlockMiner extends BlockContainerBase implements IHudDisplay{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Override
public TileEntity createNewTileEntity(World world, int i){
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityMiner();
}
@Override
@SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) {
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
if(tile instanceof TileEntityMiner){
TileEntityMiner miner = (TileEntityMiner)tile;
String info = miner.checkY == 0 ? "Done Mining!" : miner.checkY == -1 ? "Calculating positions..." : "Mining at "+(miner.getPos().getX()+miner.checkX)+", "+miner.checkY+", "+(miner.getPos().getZ()+miner.checkZ)+".";
minecraft.fontRenderer.drawStringWithShadow(info, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-20, StringUtil.DECIMAL_COLOR_WHITE);
if (tile instanceof TileEntityMiner) {
TileEntityMiner miner = (TileEntityMiner) tile;
String info = miner.checkY == 0 ? "Done Mining!" : miner.checkY == -1 ? "Calculating positions..." : "Mining at " + (miner.getPos().getX() + miner.checkX) + ", " + miner.checkY + ", " + (miner.getPos().getZ() + miner.checkZ) + ".";
minecraft.fontRenderer.drawStringWithShadow(info, resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 - 20, StringUtil.DECIMAL_COLOR_WHITE);
}
}
}

View file

@ -25,12 +25,12 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
public class BlockMisc extends BlockBase{
public class BlockMisc extends BlockBase {
public static final TheMiscBlocks[] ALL_MISC_BLOCKS = TheMiscBlocks.values();
public static final PropertyEnum<TheMiscBlocks> TYPE = PropertyEnum.create("type", TheMiscBlocks.class);
public BlockMisc(String name){
public BlockMisc(String name) {
super(Material.ROCK, name);
this.setHardness(1.5F);
this.setResistance(10.0F);
@ -38,66 +38,65 @@ public class BlockMisc extends BlockBase{
}
@Override
public int damageDropped(IBlockState state){
public int damageDropped(IBlockState state) {
return this.getMetaFromState(state);
}
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list){
for(int j = 0; j < ALL_MISC_BLOCKS.length; j++){
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (int j = 0; j < ALL_MISC_BLOCKS.length; j++) {
list.add(new ItemStack(this, 1, j));
}
}
@Override
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new TheItemBlock(this);
}
@Override
public void registerRendering(){
for(int i = 0; i < ALL_MISC_BLOCKS.length; i++){
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName()+"="+ALL_MISC_BLOCKS[i].name);
public void registerRendering() {
for (int i = 0; i < ALL_MISC_BLOCKS.length; i++) {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName() + "=" + ALL_MISC_BLOCKS[i].name);
}
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return stack.getItemDamage() >= ALL_MISC_BLOCKS.length ? EnumRarity.COMMON : ALL_MISC_BLOCKS[stack.getItemDamage()].rarity;
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(TYPE, TheMiscBlocks.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(TYPE).ordinal();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, TYPE);
}
public static class TheItemBlock extends ItemBlockBase{
public static class TheItemBlock extends ItemBlockBase {
public TheItemBlock(Block block){
public TheItemBlock(Block block) {
super(block);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
@Override
public String getTranslationKey(ItemStack stack){
return stack.getItemDamage() >= ALL_MISC_BLOCKS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey()+"_"+ALL_MISC_BLOCKS[stack.getItemDamage()].name;
public String getTranslationKey(ItemStack stack) {
return stack.getItemDamage() >= ALL_MISC_BLOCKS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey() + "_" + ALL_MISC_BLOCKS[stack.getItemDamage()].name;
}
@Override
public int getItemBurnTime(ItemStack stack) {
if(stack.getMetadata() == TheMiscBlocks.CHARCOAL_BLOCK.ordinal()) return 16000;
if (stack.getMetadata() == TheMiscBlocks.CHARCOAL_BLOCK.ordinal()) return 16000;
return super.getItemBurnTime(stack);
}
}

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.Random;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
@ -25,17 +26,19 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Random;
public class BlockOilGenerator extends BlockContainerBase {
public class BlockOilGenerator extends BlockContainerBase{
public BlockOilGenerator(String name){
public BlockOilGenerator(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -45,39 +48,39 @@ public class BlockOilGenerator extends BlockContainerBase{
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityOilGenerator();
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityOilGenerator){
if(((TileEntityOilGenerator)tile).currentBurnTime > 0){
for(int i = 0; i < 5; i++){
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D);
if (tile instanceof TileEntityOilGenerator) {
if (((TileEntityOilGenerator) tile).currentBurnTime > 0) {
for (int i = 0; i < 5; i++) {
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) pos.getX() + 0.5F, (double) pos.getY() + 1.0F, (double) pos.getZ() + 0.5F, 0.0D, 0.0D, 0.0D);
}
}
}
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityOilGenerator generator = (TileEntityOilGenerator)world.getTileEntity(pos);
if(generator != null){
if(!this.tryUseItemOnTank(player, hand, generator.tank)){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
TileEntityOilGenerator generator = (TileEntityOilGenerator) world.getTileEntity(pos);
if (generator != null) {
if (!this.tryUseItemOnTank(player, hand, generator.tank)) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.OIL_GENERATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
@ -87,39 +90,39 @@ public class BlockOilGenerator extends BlockContainerBase{
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockHorizontal.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING)));
}
}

View file

@ -13,7 +13,12 @@ package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.*;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomBreaker;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomEnergyface;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomItemface;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomLiquiface;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomRedstoneface;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
@ -38,11 +43,11 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
public class BlockPhantom extends BlockContainerBase implements IHudDisplay {
public final Type type;
public BlockPhantom(Type type, String name){
public BlockPhantom(Type type, String name) {
super(Material.ROCK, name);
this.type = type;
this.setHarvestLevel("pickaxe", 0);
@ -52,40 +57,36 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
}
@Override
public boolean canProvidePower(IBlockState state){
public boolean canProvidePower(IBlockState state) {
return this.type == Type.REDSTONEFACE;
}
@Override
public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side){
if(this.type == Type.REDSTONEFACE){
public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
if (this.type == Type.REDSTONEFACE) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityPhantomRedstoneface){
return ((TileEntityPhantomRedstoneface)tile).providesWeak[side.ordinal()];
}
if (tile instanceof TileEntityPhantomRedstoneface) { return ((TileEntityPhantomRedstoneface) tile).providesWeak[side.ordinal()]; }
}
return 0;
}
@Override
public int getStrongPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side){
if(this.type == Type.REDSTONEFACE){
public int getStrongPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
if (this.type == Type.REDSTONEFACE) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityPhantomRedstoneface){
return ((TileEntityPhantomRedstoneface)tile).providesStrong[side.ordinal()];
}
if (tile instanceof TileEntityPhantomRedstoneface) { return ((TileEntityPhantomRedstoneface) tile).providesStrong[side.ordinal()]; }
}
return 0;
}
@Override
public boolean shouldDropInventory(World world, BlockPos pos){
public boolean shouldDropInventory(World world, BlockPos pos) {
return this.type == Type.PLACER || this.type == Type.BREAKER;
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
switch(this.type){
public TileEntity createNewTileEntity(World world, int par2) {
switch (this.type) {
case PLACER:
return new TileEntityPhantomPlacer();
case BREAKER:
@ -102,55 +103,51 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ){
if(this.tryToggleRedstone(world, pos, player)){
return true;
}
if(!world.isRemote){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (this.tryToggleRedstone(world, pos, player)) { return true; }
if (!world.isRemote) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof IPhantomTile && ((IPhantomTile)tile).getGuiID() != -1){
player.openGui(ActuallyAdditions.INSTANCE, ((IPhantomTile)tile).getGuiID(), world, pos.getX(), pos.getY(), pos.getZ());
if (tile instanceof IPhantomTile && ((IPhantomTile) tile).getGuiID() != -1) {
player.openGui(ActuallyAdditions.INSTANCE, ((IPhantomTile) tile).getGuiID(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
return true;
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
@SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) {
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
if(tile != null){
if(tile instanceof IPhantomTile){
IPhantomTile phantom = (IPhantomTile)tile;
minecraft.fontRenderer.drawStringWithShadow(TextFormatting.GOLD+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".blockPhantomRange.desc")+": "+phantom.getRange(), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-40, StringUtil.DECIMAL_COLOR_WHITE);
if(phantom.hasBoundPosition()){
if (tile != null) {
if (tile instanceof IPhantomTile) {
IPhantomTile phantom = (IPhantomTile) tile;
minecraft.fontRenderer.drawStringWithShadow(TextFormatting.GOLD + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".blockPhantomRange.desc") + ": " + phantom.getRange(), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 - 40, StringUtil.DECIMAL_COLOR_WHITE);
if (phantom.hasBoundPosition()) {
int distance = MathHelper.ceil(new Vec3d(posHit.getBlockPos()).distanceTo(new Vec3d(phantom.getBoundPosition())));
IBlockState state = minecraft.world.getBlockState(phantom.getBoundPosition());
Block block = state.getBlock();
Item item = Item.getItemFromBlock(block);
String name = item == null ? "Something Unrecognizable" : item.getItemStackDisplayName(new ItemStack(block, 1, block.getMetaFromState(state)));
StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localizeFormatted("tooltip."+ActuallyAdditions.MODID+".phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-30, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localizeFormatted("tooltip." + ActuallyAdditions.MODID + ".phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 - 30, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
if(phantom.isBoundThingInRange()){
StringUtil.drawSplitString(minecraft.fontRenderer, TextFormatting.DARK_GREEN+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".phantom.connectedRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
if (phantom.isBoundThingInRange()) {
StringUtil.drawSplitString(minecraft.fontRenderer, TextFormatting.DARK_GREEN + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".phantom.connectedRange.desc"), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 25, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
} else {
StringUtil.drawSplitString(minecraft.fontRenderer, TextFormatting.DARK_RED + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".phantom.connectedNoRange.desc"), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 25, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
}
else{
StringUtil.drawSplitString(minecraft.fontRenderer, TextFormatting.DARK_RED+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".phantom.connectedNoRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
}
}
else{
minecraft.fontRenderer.drawStringWithShadow(TextFormatting.RED+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".phantom.notConnected.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, StringUtil.DECIMAL_COLOR_WHITE);
} else {
minecraft.fontRenderer.drawStringWithShadow(TextFormatting.RED + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".phantom.notConnected.desc"), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 25, StringUtil.DECIMAL_COLOR_WHITE);
}
}
}
}
public enum Type{
public enum Type {
FACE,
PLACER,
BREAKER,

View file

@ -23,11 +23,11 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockPhantomBooster extends BlockContainerBase{
public class BlockPhantomBooster extends BlockContainerBase {
private static final AxisAlignedBB AABB = new AxisAlignedBB(2*0.0625, 0, 2*0.0625, 1-2*0.0625, 1, 1-2*0.0625);
private static final AxisAlignedBB AABB = new AxisAlignedBB(2 * 0.0625, 0, 2 * 0.0625, 1 - 2 * 0.0625, 1, 1 - 2 * 0.0625);
public BlockPhantomBooster(String name){
public BlockPhantomBooster(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -36,28 +36,27 @@ public class BlockPhantomBooster extends BlockContainerBase{
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return AABB;
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
public TileEntity createNewTileEntity(World world, int i){
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityPhantomBooster();
}
}

View file

@ -30,9 +30,9 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockPlayerInterface extends BlockContainerBase implements IHudDisplay{
public class BlockPlayerInterface extends BlockContainerBase implements IHudDisplay {
public BlockPlayerInterface(String name){
public BlockPlayerInterface(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(4.5F);
@ -41,21 +41,21 @@ public class BlockPlayerInterface extends BlockContainerBase implements IHudDisp
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityPlayerInterface();
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityPlayerInterface){
TileEntityPlayerInterface face = (TileEntityPlayerInterface)tile;
if(face.connectedPlayer == null){
if (tile instanceof TileEntityPlayerInterface) {
TileEntityPlayerInterface face = (TileEntityPlayerInterface) tile;
if (face.connectedPlayer == null) {
face.connectedPlayer = player.getUniqueID();
face.playerName = player.getName();
face.markDirty();
@ -68,14 +68,14 @@ public class BlockPlayerInterface extends BlockContainerBase implements IHudDisp
@Override
@SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) {
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
if(tile != null){
if(tile instanceof TileEntityPlayerInterface){
TileEntityPlayerInterface face = (TileEntityPlayerInterface)tile;
if (tile != null) {
if (tile instanceof TileEntityPlayerInterface) {
TileEntityPlayerInterface face = (TileEntityPlayerInterface) tile;
String name = face.playerName == null ? "Unknown" : face.playerName;
minecraft.fontRenderer.drawStringWithShadow("Bound to: "+TextFormatting.RED+name, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRenderer.drawStringWithShadow("UUID: "+TextFormatting.DARK_GREEN+face.connectedPlayer, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+15, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRenderer.drawStringWithShadow("Bound to: " + TextFormatting.RED + name, resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 5, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRenderer.drawStringWithShadow("UUID: " + TextFormatting.DARK_GREEN + face.connectedPlayer, resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 15, StringUtil.DECIMAL_COLOR_WHITE);
}
}
}

View file

@ -26,9 +26,9 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockRangedCollector extends BlockContainerBase{
public class BlockRangedCollector extends BlockContainerBase {
public BlockRangedCollector(String name){
public BlockRangedCollector(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
@ -36,20 +36,17 @@ public class BlockRangedCollector extends BlockContainerBase{
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityRangedCollector();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(this.tryToggleRedstone(world, pos, player)){
return true;
}
if(!world.isRemote){
TileEntityRangedCollector breaker = (TileEntityRangedCollector)world.getTileEntity(pos);
if(breaker != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (this.tryToggleRedstone(world, pos, player)) { return true; }
if (!world.isRemote) {
TileEntityRangedCollector breaker = (TileEntityRangedCollector) world.getTileEntity(pos);
if (breaker != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.RANGED_COLLECTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
@ -58,7 +55,7 @@ public class BlockRangedCollector extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
}

View file

@ -10,6 +10,10 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityShockSuppressor;
import net.minecraft.block.SoundType;
@ -24,13 +28,9 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.ExplosionEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class BlockShockSuppressor extends BlockContainerBase {
public class BlockShockSuppressor extends BlockContainerBase{
public BlockShockSuppressor(String name){
public BlockShockSuppressor(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(20.0F);
@ -41,29 +41,29 @@ public class BlockShockSuppressor extends BlockContainerBase{
}
@SubscribeEvent
public void onExplosion(ExplosionEvent.Detonate event){
public void onExplosion(ExplosionEvent.Detonate event) {
World world = event.getWorld();
if(!world.isRemote){
if (!world.isRemote) {
List<BlockPos> affectedBlocks = event.getAffectedBlocks();
List<Entity> affectedEntities = event.getAffectedEntities();
int rangeSq = TileEntityShockSuppressor.RANGE*TileEntityShockSuppressor.RANGE;
int rangeSq = TileEntityShockSuppressor.RANGE * TileEntityShockSuppressor.RANGE;
int use = TileEntityShockSuppressor.USE_PER;
for(TileEntityShockSuppressor suppressor : TileEntityShockSuppressor.SUPPRESSORS){
if(!suppressor.isRedstonePowered){
for (TileEntityShockSuppressor suppressor : TileEntityShockSuppressor.SUPPRESSORS) {
if (!suppressor.isRedstonePowered) {
BlockPos supPos = suppressor.getPos();
List<Entity> entitiesToRemove = new ArrayList<>();
List<BlockPos> posesToRemove = new ArrayList<>();
for(BlockPos pos : affectedBlocks){
if(pos.distanceSq(supPos) <= rangeSq){
for (BlockPos pos : affectedBlocks) {
if (pos.distanceSq(supPos) <= rangeSq) {
posesToRemove.add(pos);
}
}
for(Entity entity : affectedEntities){
if(entity.getPositionVector().squareDistanceTo(supPos.getX(), supPos.getY(), supPos.getZ()) <= rangeSq){
for (Entity entity : affectedEntities) {
if (entity.getPositionVector().squareDistanceTo(supPos.getX(), supPos.getY(), supPos.getZ()) <= rangeSq) {
entitiesToRemove.add(entity);
}
}
@ -71,21 +71,19 @@ public class BlockShockSuppressor extends BlockContainerBase{
Collections.shuffle(entitiesToRemove);
Collections.shuffle(posesToRemove);
for(BlockPos pos : posesToRemove){
if(suppressor.storage.getEnergyStored() >= use){
for (BlockPos pos : posesToRemove) {
if (suppressor.storage.getEnergyStored() >= use) {
suppressor.storage.extractEnergyInternal(use, false);
affectedBlocks.remove(pos);
}
else{
} else {
break;
}
}
for(Entity entity : entitiesToRemove){
if(suppressor.storage.getEnergyStored() >= use){
for (Entity entity : entitiesToRemove) {
if (suppressor.storage.getEnergyStored() >= use) {
suppressor.storage.extractEnergyInternal(use, false);
affectedEntities.remove(entity);
}
else{
} else {
break;
}
}
@ -95,12 +93,12 @@ public class BlockShockSuppressor extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta){
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityShockSuppressor();
}
}

View file

@ -33,18 +33,18 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockSlabs extends BlockBase{
public class BlockSlabs extends BlockBase {
public static final AxisAlignedBB AABB_BOTTOM_HALF = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.5D, 1.0D);
private static final AxisAlignedBB AABB_TOP_HALF = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 1.0D, 1.0D, 1.0D);
private final IBlockState fullBlockState;
public BlockSlabs(String name, Block fullBlock){
public BlockSlabs(String name, Block fullBlock) {
this(name, fullBlock.getDefaultState());
}
public BlockSlabs(String name, IBlockState fullBlockState){
public BlockSlabs(String name, IBlockState fullBlockState) {
super(fullBlockState.getMaterial(), name);
this.setHardness(1.5F);
this.setResistance(10.0F);
@ -52,79 +52,75 @@ public class BlockSlabs extends BlockBase{
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer){
if(facing.ordinal() == 1){
return this.getStateFromMeta(meta);
}
if(facing.ordinal() == 0 || hitY >= 0.5F){
return this.getStateFromMeta(meta+1);
}
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
if (facing.ordinal() == 1) { return this.getStateFromMeta(meta); }
if (facing.ordinal() == 0 || hitY >= 0.5F) { return this.getStateFromMeta(meta + 1); }
return this.getStateFromMeta(meta);
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP ? AABB_TOP_HALF : AABB_BOTTOM_HALF;
}
@Override
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new TheItemBlock(this);
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.COMMON;
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockSlab.HALF, meta == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP);
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM ? 0 : 1;
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockSlab.HALF);
}
public static class TheItemBlock extends ItemBlockBase{
public static class TheItemBlock extends ItemBlockBase {
public TheItemBlock(Block block){
public TheItemBlock(Block block) {
super(block);
this.setHasSubtypes(false);
this.setMaxDamage(0);
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if(StackUtil.isValid(stack) && player.canPlayerEdit(pos.offset(facing), facing, stack)){
if (StackUtil.isValid(stack) && player.canPlayerEdit(pos.offset(facing), facing, stack)) {
IBlockState state = world.getBlockState(pos);
if(state.getBlock() == this.block){
BlockSlabs theBlock = (BlockSlabs)this.block;
if(facing == EnumFacing.UP && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM || facing == EnumFacing.DOWN && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP){
if (state.getBlock() == this.block) {
BlockSlabs theBlock = (BlockSlabs) this.block;
if (facing == EnumFacing.UP && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM || facing == EnumFacing.DOWN && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP) {
IBlockState newState = theBlock.fullBlockState;
AxisAlignedBB bound = newState.getCollisionBoundingBox(world, pos);
if(bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)){
if (bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)) {
SoundType soundtype = theBlock.fullBlockState.getBlock().getSoundType(theBlock.fullBlockState, world, pos, player);
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
}
@ -133,37 +129,34 @@ public class BlockSlabs extends BlockBase{
}
return this.tryPlace(player, stack, hand, world, pos.offset(facing)) ? EnumActionResult.SUCCESS : super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
}
else{
} else {
return EnumActionResult.FAIL;
}
}
@Override
@SideOnly(Side.CLIENT)
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack){
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) {
IBlockState state = worldIn.getBlockState(pos);
if(state.getBlock() == this.block){
if(side == EnumFacing.UP && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP){
return true;
}
if (state.getBlock() == this.block) {
if (side == EnumFacing.UP && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP) { return true; }
}
return worldIn.getBlockState(pos.offset(side)).getBlock() == this.block || super.canPlaceBlockOnSide(worldIn, pos, side, player, stack);
}
private boolean tryPlace(EntityPlayer player, ItemStack stack, EnumHand hand, World world, BlockPos pos){
private boolean tryPlace(EntityPlayer player, ItemStack stack, EnumHand hand, World world, BlockPos pos) {
IBlockState iblockstate = world.getBlockState(pos);
if(iblockstate.getBlock() == this.block){
BlockSlabs theBlock = (BlockSlabs)this.block;
if (iblockstate.getBlock() == this.block) {
BlockSlabs theBlock = (BlockSlabs) this.block;
IBlockState newState = theBlock.fullBlockState;
AxisAlignedBB bound = newState.getCollisionBoundingBox(world, pos);
if(bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)){
if (bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)) {
SoundType soundtype = theBlock.fullBlockState.getBlock().getSoundType(theBlock.fullBlockState, world, pos, player);
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
}
@ -174,9 +167,8 @@ public class BlockSlabs extends BlockBase{
return false;
}
@Override
public String getTranslationKey(ItemStack stack){
public String getTranslationKey(ItemStack stack) {
return this.getTranslationKey();
}
}

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.Random;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
@ -25,17 +26,19 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Random;
public class BlockSmileyCloud extends BlockContainerBase {
public class BlockSmileyCloud extends BlockContainerBase{
public BlockSmileyCloud(String name){
public BlockSmileyCloud(String name) {
super(Material.CLOTH, name);
this.setHardness(0.5F);
this.setResistance(5.0F);
@ -44,33 +47,33 @@ public class BlockSmileyCloud extends BlockContainerBase{
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){
if(world.rand.nextInt(30) == 0){
for(int i = 0; i < 2; i++){
double d = world.rand.nextGaussian()*0.02D;
double d1 = world.rand.nextGaussian()*0.02D;
double d2 = world.rand.nextGaussian()*0.02D;
world.spawnParticle(EnumParticleTypes.HEART, pos.getX()+world.rand.nextFloat(), pos.getY()+0.65+world.rand.nextFloat(), pos.getZ()+world.rand.nextFloat(), d, d1, d2);
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
if (world.rand.nextInt(30) == 0) {
for (int i = 0; i < 2; i++) {
double d = world.rand.nextGaussian() * 0.02D;
double d1 = world.rand.nextGaussian() * 0.02D;
double d2 = world.rand.nextGaussian() * 0.02D;
world.spawnParticle(EnumParticleTypes.HEART, pos.getX() + world.rand.nextFloat(), pos.getY() + 0.65 + world.rand.nextFloat(), pos.getZ() + world.rand.nextFloat(), d, d1, d2);
}
}
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing f6, float f7, float f8, float f9){
if(!world.isRemote){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing f6, float f7, float f8, float f9) {
if (!world.isRemote) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntitySmileyCloud){
if (tile instanceof TileEntitySmileyCloud) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.CLOUD.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
//TheAchievements.NAME_SMILEY_CLOUD.get(player);
@ -79,46 +82,45 @@ public class BlockSmileyCloud extends BlockContainerBase{
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int meta){
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntitySmileyCloud();
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockHorizontal.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING)));
}
}

View file

@ -10,6 +10,10 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.Random;
import javax.annotation.Nullable;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTorch;
@ -19,7 +23,11 @@ import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.*;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
@ -27,12 +35,9 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.Random;
//Copied from BlockTorch.
//I have no idea what all of this means.
public class BlockTinyTorch extends BlockBase{
public class BlockTinyTorch extends BlockBase {
//Thanks to xdjackiexd for these.
//Man, I hate numbers.
@ -42,7 +47,7 @@ public class BlockTinyTorch extends BlockBase{
private static final AxisAlignedBB TORCH_WEST_AABB = new AxisAlignedBB(0.8125D, 0.25D, 0.4375D, 1.0D, 0.5625D, 0.5625D);
private static final AxisAlignedBB TORCH_EAST_AABB = new AxisAlignedBB(0.0D, 0.25D, 0.4375D, 0.1875D, 0.5625D, 0.5625D);
public BlockTinyTorch(String name){
public BlockTinyTorch(String name) {
super(Material.CIRCUITS, name);
this.setDefaultState(this.blockState.getBaseState().withProperty(BlockTorch.FACING, EnumFacing.UP));
this.setTickRandomly(true);
@ -53,8 +58,8 @@ public class BlockTinyTorch extends BlockBase{
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
switch(state.getValue(BlockTorch.FACING)){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
switch (state.getValue(BlockTorch.FACING)) {
case EAST:
return TORCH_EAST_AABB;
case WEST:
@ -70,22 +75,22 @@ public class BlockTinyTorch extends BlockBase{
@Nullable
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos){
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
return NULL_AABB;
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isNormalCube(IBlockState state){
public boolean isNormalCube(IBlockState state) {
return false;
}
@ -94,38 +99,33 @@ public class BlockTinyTorch extends BlockBase{
return BlockFaceShape.UNDEFINED;
}
private boolean canPlaceOn(World worldIn, BlockPos pos){
private boolean canPlaceOn(World worldIn, BlockPos pos) {
IBlockState state = worldIn.getBlockState(pos);
return state.isSideSolid(worldIn, pos, EnumFacing.UP) || state.getBlock().canPlaceTorchOnTop(state, worldIn, pos);
}
@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos){
for(EnumFacing enumfacing : BlockTorch.FACING.getAllowedValues()){
if(this.canPlaceAt(worldIn, pos, enumfacing)){
return true;
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
for (EnumFacing enumfacing : BlockTorch.FACING.getAllowedValues()) {
if (this.canPlaceAt(worldIn, pos, enumfacing)) { return true; }
}
return false;
}
private boolean canPlaceAt(World worldIn, BlockPos pos, EnumFacing facing){
private boolean canPlaceAt(World worldIn, BlockPos pos, EnumFacing facing) {
BlockPos blockpos = pos.offset(facing.getOpposite());
boolean flag = facing.getAxis().isHorizontal();
return flag && worldIn.isSideSolid(blockpos, facing, true) || facing.equals(EnumFacing.UP) && this.canPlaceOn(worldIn, blockpos);
}
@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer){
if(this.canPlaceAt(worldIn, pos, facing)){
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
if (this.canPlaceAt(worldIn, pos, facing)) {
return this.getDefaultState().withProperty(BlockTorch.FACING, facing);
}
else{
for(EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL){
if(worldIn.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true)){
return this.getDefaultState().withProperty(BlockTorch.FACING, enumfacing);
}
} else {
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) {
if (worldIn.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true)) { return this.getDefaultState().withProperty(BlockTorch.FACING, enumfacing); }
}
return this.getDefaultState();
@ -133,49 +133,45 @@ public class BlockTinyTorch extends BlockBase{
}
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state){
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
this.checkForDrop(worldIn, pos, state);
}
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos otherPos){
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos otherPos) {
this.onNeighborChangeInternal(worldIn, pos, state);
}
protected boolean onNeighborChangeInternal(World worldIn, BlockPos pos, IBlockState state){
if(!this.checkForDrop(worldIn, pos, state)){
protected boolean onNeighborChangeInternal(World worldIn, BlockPos pos, IBlockState state) {
if (!this.checkForDrop(worldIn, pos, state)) {
return true;
}
else{
} else {
EnumFacing enumfacing = state.getValue(BlockTorch.FACING);
EnumFacing.Axis axis = enumfacing.getAxis();
EnumFacing enumfacing1 = enumfacing.getOpposite();
boolean flag = false;
if(axis.isHorizontal() && !worldIn.isSideSolid(pos.offset(enumfacing1), enumfacing, true)){
if (axis.isHorizontal() && !worldIn.isSideSolid(pos.offset(enumfacing1), enumfacing, true)) {
flag = true;
}
else if(axis.isVertical() && !this.canPlaceOn(worldIn, pos.offset(enumfacing1))){
} else if (axis.isVertical() && !this.canPlaceOn(worldIn, pos.offset(enumfacing1))) {
flag = true;
}
if(flag){
if (flag) {
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
return true;
}
else{
} else {
return false;
}
}
}
protected boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state){
if(state.getBlock() == this && this.canPlaceAt(worldIn, pos, state.getValue(BlockTorch.FACING))){
protected boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state) {
if (state.getBlock() == this && this.canPlaceAt(worldIn, pos, state.getValue(BlockTorch.FACING))) {
return true;
}
else{
if(worldIn.getBlockState(pos).getBlock() == this){
} else {
if (worldIn.getBlockState(pos).getBlock() == this) {
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
@ -186,19 +182,18 @@ public class BlockTinyTorch extends BlockBase{
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand){
if(rand.nextBoolean()){
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
if (rand.nextBoolean()) {
EnumFacing enumfacing = stateIn.getValue(BlockTorch.FACING);
double d0 = pos.getX()+0.5D;
double d1 = pos.getY()+0.4D;
double d2 = pos.getZ()+0.5D;
double d0 = pos.getX() + 0.5D;
double d1 = pos.getY() + 0.4D;
double d2 = pos.getZ() + 0.5D;
if(enumfacing.getAxis().isHorizontal()){
if (enumfacing.getAxis().isHorizontal()) {
EnumFacing enumfacing1 = enumfacing.getOpposite();
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0+0.35D*enumfacing1.getXOffset(), d1+0.22D, d2+0.35D*enumfacing1.getZOffset(), 0.0D, 0.0D, 0.0D);
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0+0.35D*enumfacing1.getXOffset(), d1+0.22D, d2+0.35D*enumfacing1.getZOffset(), 0.0D, 0.0D, 0.0D);
}
else{
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + 0.35D * enumfacing1.getXOffset(), d1 + 0.22D, d2 + 0.35D * enumfacing1.getZOffset(), 0.0D, 0.0D, 0.0D);
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + 0.35D * enumfacing1.getXOffset(), d1 + 0.22D, d2 + 0.35D * enumfacing1.getZOffset(), 0.0D, 0.0D, 0.0D);
} else {
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D);
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
@ -206,10 +201,10 @@ public class BlockTinyTorch extends BlockBase{
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
IBlockState iblockstate = this.getDefaultState();
switch(meta){
switch (meta) {
case 1:
iblockstate = iblockstate.withProperty(BlockTorch.FACING, EnumFacing.EAST);
break;
@ -231,15 +226,15 @@ public class BlockTinyTorch extends BlockBase{
}
@Override
public BlockRenderLayer getRenderLayer(){
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
int i = 0;
switch(state.getValue(BlockTorch.FACING)){
switch (state.getValue(BlockTorch.FACING)) {
case EAST:
i = i | 1;
break;
@ -262,17 +257,17 @@ public class BlockTinyTorch extends BlockBase{
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockTorch.FACING, rot.rotate(state.getValue(BlockTorch.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirrorIn){
public IBlockState withMirror(IBlockState state, Mirror mirrorIn) {
return state.withRotation(mirrorIn.toRotation(state.getValue(BlockTorch.FACING)));
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockTorch.FACING);
}
}

View file

@ -41,9 +41,9 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockTreasureChest extends BlockBase{
public class BlockTreasureChest extends BlockBase {
public BlockTreasureChest(String name){
public BlockTreasureChest(String name) {
super(Material.WOOD, name);
this.setHarvestLevel("axe", 0);
this.setHardness(300.0F);
@ -54,25 +54,25 @@ public class BlockTreasureChest extends BlockBase{
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){
for(int i = 0; i < 2; i++){
for(float f = 0; f <= 3; f += 0.5){
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
for (int i = 0; i < 2; i++) {
for (float f = 0; f <= 3; f += 0.5) {
float particleX = rand.nextFloat();
float particleZ = rand.nextFloat();
world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, (double)pos.getX()+particleX, (double)pos.getY()+f+1, (double)pos.getZ()+particleZ, 0.0D, 0.2D, 0.0D);
world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, (double) pos.getX() + particleX, (double) pos.getY() + f + 1, (double) pos.getZ() + particleZ, 0.0D, 0.2D, 0.0D);
}
}
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int par3){
public Item getItemDropped(IBlockState state, Random rand, int par3) {
return Items.AIR;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.2F, world.rand.nextFloat()*0.1F+0.9F);
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.2F, world.rand.nextFloat() * 0.1F + 0.9F);
this.dropItems(world, pos);
world.setBlockToAir(pos);
@ -82,62 +82,62 @@ public class BlockTreasureChest extends BlockBase{
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
}
@Override
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player){
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
return false;
}
private void dropItems(World world, BlockPos pos){
for(int i = 0; i < MathHelper.getInt(world.rand, 3, 6); i++){
private void dropItems(World world, BlockPos pos) {
for (int i = 0; i < MathHelper.getInt(world.rand, 3, 6); i++) {
TreasureChestLoot theReturn = WeightedRandom.getRandomItem(world.rand, ActuallyAdditionsAPI.TREASURE_CHEST_LOOT);
ItemStack itemStack = theReturn.returnItem.copy();
itemStack.setCount(MathHelper.getInt(world.rand, theReturn.minAmount, theReturn.maxAmount));
float dX = world.rand.nextFloat()*0.8F+0.1F;
float dY = world.rand.nextFloat()*0.8F+0.1F;
float dZ = world.rand.nextFloat()*0.8F+0.1F;
EntityItem entityItem = new EntityItem(world, pos.getX()+dX, pos.getY()+dY, pos.getZ()+dZ, itemStack);
float dX = world.rand.nextFloat() * 0.8F + 0.1F;
float dY = world.rand.nextFloat() * 0.8F + 0.1F;
float dZ = world.rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ, itemStack);
float factor = 0.05F;
entityItem.motionX = world.rand.nextGaussian()*factor;
entityItem.motionY = world.rand.nextGaussian()*factor+0.2F;
entityItem.motionZ = world.rand.nextGaussian()*factor;
entityItem.motionX = world.rand.nextGaussian() * factor;
entityItem.motionY = world.rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = world.rand.nextGaussian() * factor;
world.spawnEntity(entityItem);
}
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockHorizontal.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING)));
}
}

View file

@ -28,13 +28,13 @@ import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockWallAA extends BlockBase{
public class BlockWallAA extends BlockBase {
protected static final AxisAlignedBB[] AABB_BY_INDEX = new AxisAlignedBB[]{new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.3125D, 0.0D, 0.0D, 0.6875D, 0.875D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.3125D, 1.0D, 0.875D, 0.6875D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D)};
protected static final AxisAlignedBB[] CLIP_AABB_BY_INDEX = new AxisAlignedBB[]{AABB_BY_INDEX[0].setMaxY(1.5D), AABB_BY_INDEX[1].setMaxY(1.5D), AABB_BY_INDEX[2].setMaxY(1.5D), AABB_BY_INDEX[3].setMaxY(1.5D), AABB_BY_INDEX[4].setMaxY(1.5D), AABB_BY_INDEX[5].setMaxY(1.5D), AABB_BY_INDEX[6].setMaxY(1.5D), AABB_BY_INDEX[7].setMaxY(1.5D), AABB_BY_INDEX[8].setMaxY(1.5D), AABB_BY_INDEX[9].setMaxY(1.5D), AABB_BY_INDEX[10].setMaxY(1.5D), AABB_BY_INDEX[11].setMaxY(1.5D), AABB_BY_INDEX[12].setMaxY(1.5D), AABB_BY_INDEX[13].setMaxY(1.5D), AABB_BY_INDEX[14].setMaxY(1.5D), AABB_BY_INDEX[15].setMaxY(1.5D)};
protected static final AxisAlignedBB[] AABB_BY_INDEX = new AxisAlignedBB[] { new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.3125D, 0.0D, 0.0D, 0.6875D, 0.875D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.3125D, 1.0D, 0.875D, 0.6875D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D) };
protected static final AxisAlignedBB[] CLIP_AABB_BY_INDEX = new AxisAlignedBB[] { AABB_BY_INDEX[0].setMaxY(1.5D), AABB_BY_INDEX[1].setMaxY(1.5D), AABB_BY_INDEX[2].setMaxY(1.5D), AABB_BY_INDEX[3].setMaxY(1.5D), AABB_BY_INDEX[4].setMaxY(1.5D), AABB_BY_INDEX[5].setMaxY(1.5D), AABB_BY_INDEX[6].setMaxY(1.5D), AABB_BY_INDEX[7].setMaxY(1.5D), AABB_BY_INDEX[8].setMaxY(1.5D), AABB_BY_INDEX[9].setMaxY(1.5D), AABB_BY_INDEX[10].setMaxY(1.5D), AABB_BY_INDEX[11].setMaxY(1.5D), AABB_BY_INDEX[12].setMaxY(1.5D), AABB_BY_INDEX[13].setMaxY(1.5D), AABB_BY_INDEX[14].setMaxY(1.5D), AABB_BY_INDEX[15].setMaxY(1.5D) };
@SuppressWarnings("deprecation")
public BlockWallAA(String name, Block blocc){
public BlockWallAA(String name, Block blocc) {
super(blocc.getDefaultState().getMaterial(), name);
this.setHardness(1.5F);
this.setResistance(10F);
@ -42,22 +42,22 @@ public class BlockWallAA extends BlockBase{
this.setDefaultState(this.blockState.getBaseState().withProperty(BlockWall.UP, false).withProperty(BlockWall.NORTH, false).withProperty(BlockWall.EAST, false).withProperty(BlockWall.SOUTH, false).withProperty(BlockWall.WEST, false));
}
private static int yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(IBlockState state){
private static int yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(IBlockState state) {
int i = 0;
if(state.getValue(BlockWall.NORTH)){
if (state.getValue(BlockWall.NORTH)) {
i |= 1 << EnumFacing.NORTH.getHorizontalIndex();
}
if(state.getValue(BlockWall.EAST)){
if (state.getValue(BlockWall.EAST)) {
i |= 1 << EnumFacing.EAST.getHorizontalIndex();
}
if(state.getValue(BlockWall.SOUTH)){
if (state.getValue(BlockWall.SOUTH)) {
i |= 1 << EnumFacing.SOUTH.getHorizontalIndex();
}
if(state.getValue(BlockWall.WEST)){
if (state.getValue(BlockWall.WEST)) {
i |= 1 << EnumFacing.WEST.getHorizontalIndex();
}
@ -65,7 +65,7 @@ public class BlockWallAA extends BlockBase{
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos){
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
boolean flag = this.canConnectTo(worldIn, pos.north());
boolean flag1 = this.canConnectTo(worldIn, pos.east());
boolean flag2 = this.canConnectTo(worldIn, pos.south());
@ -75,65 +75,63 @@ public class BlockWallAA extends BlockBase{
}
@Override
public boolean isFullCube(IBlockState state){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isPassable(IBlockAccess worldIn, BlockPos pos){
public boolean isPassable(IBlockAccess worldIn, BlockPos pos) {
return false;
}
@Override
@SideOnly(Side.CLIENT)
@Deprecated
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side){
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
return side != EnumFacing.DOWN || super.shouldSideBeRendered(blockState, blockAccess, pos, side);
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
state = this.getActualState(state, source, pos);
return AABB_BY_INDEX[yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(state)];
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos){
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
blockState = this.getActualState(blockState, worldIn, pos);
return CLIP_AABB_BY_INDEX[yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(blockState)];
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list){
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
list.add(new ItemStack(this, 1, 0));
}
public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos){
public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos) {
IBlockState state = worldIn.getBlockState(pos);
Block block = state.getBlock();
return block != Blocks.BARRIER && (!(block != this && !(block instanceof BlockFenceGate)) || state.getMaterial().isOpaque() && state.isFullCube() && state.getMaterial() != Material.GOURD);
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState();
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return 0;
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockWall.UP, BlockWall.NORTH, BlockWall.EAST, BlockWall.WEST, BlockWall.SOUTH);
}
}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBushBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant;
@ -35,98 +34,96 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockWildPlant extends BlockBushBase{
public class BlockWildPlant extends BlockBushBase {
public static final TheWildPlants[] ALL_WILD_PLANTS = TheWildPlants.values();
public static final PropertyEnum<TheWildPlants> TYPE = PropertyEnum.create("type", TheWildPlants.class);
public BlockWildPlant(String name){
public BlockWildPlant(String name) {
super(name);
this.setSoundType(SoundType.PLANT);
}
@Override
public boolean canBlockStay(World world, BlockPos pos, IBlockState state){
public boolean canBlockStay(World world, BlockPos pos, IBlockState state) {
BlockPos offset = pos.down();
IBlockState offsetState = world.getBlockState(offset);
Block offsetBlock = offsetState.getBlock();
return state.getValue(TYPE) == TheWildPlants.RICE ? offsetState.getMaterial() == Material.WATER : offsetBlock.canSustainPlant(offsetState, world, offset, EnumFacing.UP, this);
}
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player){
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
BlockPlant normal = (BlockPlant) state.getValue(TYPE).getNormalVersion();
return new ItemStack(normal.seedItem);
}
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list){
for(int j = 0; j < ALL_WILD_PLANTS.length; j++){
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (int j = 0; j < ALL_WILD_PLANTS.length; j++) {
list.add(new ItemStack(this, 1, j));
}
}
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune){
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
Block normal = state.getValue(TYPE).getNormalVersion();
normal.getDrops(drops, world, pos, normal.getDefaultState().withProperty(BlockCrops.AGE, 7), fortune);
}
@Override
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player){
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
return false;
}
@Override
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new TheItemBlock(this);
}
@Override
public boolean shouldAddCreative(){
public boolean shouldAddCreative() {
return false;
}
@Override
public void registerRendering(){
for(int i = 0; i < ALL_WILD_PLANTS.length; i++){
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName()+"="+ALL_WILD_PLANTS[i].getName());
public void registerRendering() {
for (int i = 0; i < ALL_WILD_PLANTS.length; i++) {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName() + "=" + ALL_WILD_PLANTS[i].getName());
}
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(TYPE, TheWildPlants.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(TYPE).ordinal();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, TYPE);
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return stack.getItemDamage() >= ALL_WILD_PLANTS.length ? EnumRarity.COMMON : ALL_WILD_PLANTS[stack.getItemDamage()].getRarity();
}
public static class TheItemBlock extends ItemBlockBase{
public static class TheItemBlock extends ItemBlockBase {
public TheItemBlock(Block block){
public TheItemBlock(Block block) {
super(block);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
@Override
public String getTranslationKey(ItemStack stack){
return stack.getItemDamage() >= ALL_WILD_PLANTS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey()+"_"+ALL_WILD_PLANTS[stack.getItemDamage()].getName();
public String getTranslationKey(ItemStack stack) {
return stack.getItemDamage() >= ALL_WILD_PLANTS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey() + "_" + ALL_WILD_PLANTS[stack.getItemDamage()].getName();
}
}
}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
@ -32,9 +31,9 @@ import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockXPSolidifier extends BlockContainerBase{
public class BlockXPSolidifier extends BlockContainerBase {
public BlockXPSolidifier(String name){
public BlockXPSolidifier(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(2.5F);
@ -42,17 +41,16 @@ public class BlockXPSolidifier extends BlockContainerBase{
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityXPSolidifier();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityXPSolidifier solidifier = (TileEntityXPSolidifier)world.getTileEntity(pos);
if(solidifier != null){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
if (!world.isRemote) {
TileEntityXPSolidifier solidifier = (TileEntityXPSolidifier) world.getTileEntity(pos);
if (solidifier != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.XP_SOLIDIFIER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
@ -61,39 +59,39 @@ public class BlockXPSolidifier extends BlockContainerBase{
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
}
@Override
public IBlockState getStateFromMeta(int meta){
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state){
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
}
@Override
protected BlockStateContainer createBlockState(){
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockHorizontal.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror){
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING)));
}
}

View file

@ -18,7 +18,7 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public interface IHudDisplay{
public interface IHudDisplay {
@SideOnly(Side.CLIENT)
void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution);

View file

@ -18,7 +18,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
import net.minecraft.block.Block;
public final class InitBlocks{
public final class InitBlocks {
public static Block blockCompost;
public static Block blockMisc;
@ -116,7 +116,7 @@ public final class InitBlocks{
public static Block blockCrystalClusterEmerald;
public static Block blockCrystalClusterIron;
public static void init(){
public static void init() {
ActuallyAdditions.LOGGER.info("Initializing Blocks...");
blockCrystalClusterRedstone = new BlockCrystalCluster("block_crystal_cluster_redstone", TheCrystals.REDSTONE);

View file

@ -19,40 +19,40 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IRarity;
public class BlockBase extends Block implements ItemBlockBase.ICustomRarity, IHasModel{
public class BlockBase extends Block implements ItemBlockBase.ICustomRarity, IHasModel {
private final String name;
public BlockBase(Material material, String name){
public BlockBase(Material material, String name) {
super(material);
this.name = name;
this.register();
}
private void register(){
private void register() {
ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
}
protected String getBaseName(){
protected String getBaseName() {
return this.name;
}
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new ItemBlockBase(this);
}
public boolean shouldAddCreative(){
public boolean shouldAddCreative() {
return true;
}
@Override
public void registerRendering(){
public void registerRendering() {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public IRarity getRarity(ItemStack stack){
public IRarity getRarity(ItemStack stack) {
return EnumRarity.COMMON;
}
}

View file

@ -18,40 +18,40 @@ import net.minecraft.block.SoundType;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
public class BlockBushBase extends BlockBush implements ItemBlockBase.ICustomRarity, IHasModel{
public class BlockBushBase extends BlockBush implements ItemBlockBase.ICustomRarity, IHasModel {
private final String name;
public BlockBushBase(String name){
public BlockBushBase(String name) {
this.name = name;
this.setSoundType(SoundType.PLANT);
this.register();
}
private void register(){
private void register() {
ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
}
protected String getBaseName(){
protected String getBaseName() {
return this.name;
}
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new ItemBlockBase(this);
}
public boolean shouldAddCreative(){
public boolean shouldAddCreative() {
return true;
}
@Override
public void registerRendering(){
public void registerRendering() {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.COMMON;
}
}

View file

@ -10,6 +10,12 @@
package de.ellpeck.actuallyadditions.mod.blocks.base;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.annotation.Nullable;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.render.IHasModel;
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
@ -42,55 +48,50 @@ import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidUtil;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public abstract class BlockContainerBase extends BlockContainer implements ItemBlockBase.ICustomRarity, IHasModel{
public abstract class BlockContainerBase extends BlockContainer implements ItemBlockBase.ICustomRarity, IHasModel {
private final String name;
public BlockContainerBase(Material material, String name){
public BlockContainerBase(Material material, String name) {
super(material);
this.name = name;
this.register();
}
private void register(){
private void register() {
ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
}
protected String getBaseName(){
protected String getBaseName() {
return this.name;
}
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new ItemBlockBase(this);
}
public boolean shouldAddCreative(){
public boolean shouldAddCreative() {
return true;
}
@Override
public void registerRendering(){
public void registerRendering() {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.COMMON;
}
private void dropInventory(World world, BlockPos position){
if(!world.isRemote){
private void dropInventory(World world, BlockPos position) {
if (!world.isRemote) {
TileEntity aTile = world.getTileEntity(position);
if(aTile instanceof TileEntityInventoryBase){
TileEntityInventoryBase tile = (TileEntityInventoryBase)aTile;
if(tile.inv.getSlots() > 0){
for(int i = 0; i < tile.inv.getSlots(); i++){
if (aTile instanceof TileEntityInventoryBase) {
TileEntityInventoryBase tile = (TileEntityInventoryBase) aTile;
if (tile.inv.getSlots() > 0) {
for (int i = 0; i < tile.inv.getSlots(); i++) {
this.dropSlotFromInventory(i, tile, world, position);
}
}
@ -98,28 +99,28 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
}
}
private void dropSlotFromInventory(int i, TileEntityInventoryBase tile, World world, BlockPos pos){
private void dropSlotFromInventory(int i, TileEntityInventoryBase tile, World world, BlockPos pos) {
ItemStack stack = tile.inv.getStackInSlot(i);
if(StackUtil.isValid(stack)){
float dX = world.rand.nextFloat()*0.8F+0.1F;
float dY = world.rand.nextFloat()*0.8F+0.1F;
float dZ = world.rand.nextFloat()*0.8F+0.1F;
EntityItem entityItem = new EntityItem(world, pos.getX()+dX, pos.getY()+dY, pos.getZ()+dZ, stack.copy());
if (StackUtil.isValid(stack)) {
float dX = world.rand.nextFloat() * 0.8F + 0.1F;
float dY = world.rand.nextFloat() * 0.8F + 0.1F;
float dZ = world.rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ, stack.copy());
float factor = 0.05F;
entityItem.motionX = world.rand.nextGaussian()*factor;
entityItem.motionY = world.rand.nextGaussian()*factor+0.2F;
entityItem.motionZ = world.rand.nextGaussian()*factor;
entityItem.motionX = world.rand.nextGaussian() * factor;
entityItem.motionY = world.rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = world.rand.nextGaussian() * factor;
world.spawnEntity(entityItem);
}
}
public boolean tryToggleRedstone(World world, BlockPos pos, EntityPlayer player){
public boolean tryToggleRedstone(World world, BlockPos pos, EntityPlayer player) {
ItemStack stack = player.getHeldItemMainhand();
if(StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator){
if (StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityBase){
TileEntityBase base = (TileEntityBase)tile;
if(!world.isRemote && base.isRedstoneToggle()){
if (tile instanceof TileEntityBase) {
TileEntityBase base = (TileEntityBase) tile;
if (!world.isRemote && base.isRedstoneToggle()) {
base.isPulseMode = !base.isPulseMode;
base.markDirty();
base.sendUpdate();
@ -131,82 +132,81 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
}
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random random){
if(!world.isRemote){
public void updateTick(World world, BlockPos pos, IBlockState state, Random random) {
if (!world.isRemote) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityBase){
TileEntityBase base = (TileEntityBase)tile;
if(base.respondsToPulses()){
if (tile instanceof TileEntityBase) {
TileEntityBase base = (TileEntityBase) tile;
if (base.respondsToPulses()) {
base.activateOnPulse();
}
}
}
}
public void neighborsChangedCustom(World world, BlockPos pos){
public void neighborsChangedCustom(World world, BlockPos pos) {
this.updateRedstoneState(world, pos);
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityBase){
TileEntityBase base = (TileEntityBase)tile;
if(base.shouldSaveDataOnChangeOrWorldStart()){
if (tile instanceof TileEntityBase) {
TileEntityBase base = (TileEntityBase) tile;
if (base.shouldSaveDataOnChangeOrWorldStart()) {
base.saveDataOnChangeOrWorldStart();
}
}
}
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos otherPos){
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos otherPos) {
this.neighborsChangedCustom(worldIn, pos);
}
@Override
public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor){
public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) {
super.onNeighborChange(world, pos, neighbor);
if(world instanceof World){
this.neighborsChangedCustom((World)world, pos);
if (world instanceof World) {
this.neighborsChangedCustom((World) world, pos);
}
}
public void updateRedstoneState(World world, BlockPos pos){
if(!world.isRemote){
public void updateRedstoneState(World world, BlockPos pos) {
if (!world.isRemote) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityBase){
TileEntityBase base = (TileEntityBase)tile;
if (tile instanceof TileEntityBase) {
TileEntityBase base = (TileEntityBase) tile;
boolean powered = world.getRedstonePowerFromNeighbors(pos) > 0;
boolean wasPowered = base.isRedstonePowered;
if(powered && !wasPowered){
if(base.respondsToPulses()){
if (powered && !wasPowered) {
if (base.respondsToPulses()) {
world.scheduleUpdate(pos, this, this.tickRate(world));
}
base.setRedstonePowered(true);
}
else if(!powered && wasPowered){
} else if (!powered && wasPowered) {
base.setRedstonePowered(false);
}
}
}
}
protected boolean tryUseItemOnTank(EntityPlayer player, EnumHand hand, FluidTank tank){
protected boolean tryUseItemOnTank(EntityPlayer player, EnumHand hand, FluidTank tank) {
ItemStack heldItem = player.getHeldItem(hand);
return StackUtil.isValid(heldItem) && FluidUtil.interactWithFluidHandler(player, hand, tank);
}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state){
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
this.updateRedstoneState(world, pos);
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack){
if(stack.hasTagCompound()){
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack) {
if (stack.hasTagCompound()) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityBase){
TileEntityBase base = (TileEntityBase)tile;
if (tile instanceof TileEntityBase) {
TileEntityBase base = (TileEntityBase) tile;
NBTTagCompound compound = stack.getTagCompound().getCompoundTag("Data");
if(compound != null){
if (compound != null) {
base.readSyncableNBT(compound, TileEntityBase.NBTType.SAVE_BLOCK);
}
}
@ -214,56 +214,54 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
}
@Override
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player){
if(!player.capabilities.isCreativeMode){
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
if (!player.capabilities.isCreativeMode) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityBase && ((TileEntityBase)tile).stopFromDropping){
player.sendMessage(new TextComponentTranslation("info."+ActuallyAdditions.MODID+".machineBroke").setStyle(new Style().setColor(TextFormatting.RED)));
if (tile instanceof TileEntityBase && ((TileEntityBase) tile).stopFromDropping) {
player.sendMessage(new TextComponentTranslation("info." + ActuallyAdditions.MODID + ".machineBroke").setStyle(new Style().setColor(TextFormatting.RED)));
}
}
}
@Override
public boolean hasComparatorInputOverride(IBlockState state){
public boolean hasComparatorInputOverride(IBlockState state) {
return true;
}
@Override
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos){
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityBase){
return ((TileEntityBase)tile).getComparatorStrength();
}
if (tile instanceof TileEntityBase) { return ((TileEntityBase) tile).getComparatorStrength(); }
return 0;
}
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune){
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityBase){
TileEntityBase base = (TileEntityBase)tile;
if(!base.stopFromDropping){
if (tile instanceof TileEntityBase) {
TileEntityBase base = (TileEntityBase) tile;
if (!base.stopFromDropping) {
NBTTagCompound data = new NBTTagCompound();
base.writeSyncableNBT(data, TileEntityBase.NBTType.SAVE_BLOCK);
//Remove unnecessarily saved default values to avoid unstackability
List<String> keysToRemove = new ArrayList<>();
for(String key : data.getKeySet()){
for (String key : data.getKeySet()) {
NBTBase tag = data.getTag(key);
//Remove only ints because they are the most common ones
//Add else if below here to remove more types
if(tag instanceof NBTTagInt){
if(((NBTTagInt)tag).getInt() == 0){
if (tag instanceof NBTTagInt) {
if (((NBTTagInt) tag).getInt() == 0) {
keysToRemove.add(key);
}
}
}
for(String key : keysToRemove){
for (String key : keysToRemove) {
data.removeTag(key);
}
ItemStack stack = new ItemStack(this.getItemDropped(state, tile.getWorld().rand, fortune), 1, this.damageDropped(state));
if(!data.isEmpty()){
if (!data.isEmpty()) {
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setTag("Data", data);
}
@ -287,20 +285,20 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
}
@Override
public EnumBlockRenderType getRenderType(IBlockState state){
public EnumBlockRenderType getRenderType(IBlockState state) {
return EnumBlockRenderType.MODEL;
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state){
if(this.shouldDropInventory(world, pos)){
public void breakBlock(World world, BlockPos pos, IBlockState state) {
if (this.shouldDropInventory(world, pos)) {
this.dropInventory(world, pos);
}
super.breakBlock(world, pos, state);
}
public boolean shouldDropInventory(World world, BlockPos pos){
public boolean shouldDropInventory(World world, BlockPos pos) {
return true;
}
}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.blocks.base;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import net.minecraft.block.material.Material;
import net.minecraft.item.EnumRarity;
@ -21,11 +20,11 @@ import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
public class BlockFluidFlowing extends BlockFluidClassic implements ItemBlockBase.ICustomRarity{
public class BlockFluidFlowing extends BlockFluidClassic implements ItemBlockBase.ICustomRarity {
private final String name;
public BlockFluidFlowing(Fluid fluid, Material material, String unlocalizedName){
public BlockFluidFlowing(Fluid fluid, Material material, String unlocalizedName) {
super(fluid, material);
this.name = unlocalizedName;
this.displacements.put(this, false);
@ -33,34 +32,34 @@ public class BlockFluidFlowing extends BlockFluidClassic implements ItemBlockBas
this.register();
}
private void register(){
private void register() {
ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
}
protected String getBaseName(){
protected String getBaseName() {
return this.name;
}
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new ItemBlockBase(this);
}
public boolean shouldAddCreative(){
public boolean shouldAddCreative() {
return false;
}
@Override
public boolean canDisplace(IBlockAccess world, BlockPos pos){
public boolean canDisplace(IBlockAccess world, BlockPos pos) {
return !world.getBlockState(pos).getMaterial().isLiquid() && super.canDisplace(world, pos);
}
@Override
public boolean displaceIfPossible(World world, BlockPos pos){
public boolean displaceIfPossible(World world, BlockPos pos) {
return !world.getBlockState(pos).getMaterial().isLiquid() && super.displaceIfPossible(world, pos);
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
}

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.blocks.base;
import java.util.Random;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.render.IHasModel;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
@ -29,9 +31,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import java.util.Random;
public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarity, IHasModel{
public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarity, IHasModel {
private final String name;
private final int minDropAmount;
@ -40,72 +40,72 @@ public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarit
private Item returnItem;
private int returnMeta;
public BlockPlant(String name, int minDropAmount, int addDropAmount){
public BlockPlant(String name, int minDropAmount, int addDropAmount) {
this.name = name;
this.minDropAmount = minDropAmount;
this.addDropAmount = addDropAmount;
this.register();
}
public void doStuff(Item seedItem, Item returnItem, int returnMeta){
public void doStuff(Item seedItem, Item returnItem, int returnMeta) {
this.seedItem = seedItem;
this.returnItem = returnItem;
this.returnMeta = returnMeta;
}
private void register(){
private void register() {
ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
}
protected String getBaseName(){
protected String getBaseName() {
return this.name;
}
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new ItemBlockBase(this);
}
public boolean shouldAddCreative(){
public boolean shouldAddCreative() {
return false;
}
@Override
public void registerRendering(){
public void registerRendering() {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Override
public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos){
public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) {
return EnumPlantType.Crop;
}
@Override
public int damageDropped(IBlockState state){
public int damageDropped(IBlockState state) {
return this.getMetaFromState(state) >= 7 ? this.returnMeta : 0;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
if(this.getMetaFromState(state) >= 7){
if(!world.isRemote){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (this.getMetaFromState(state) >= 7) {
if (!world.isRemote) {
NonNullList<ItemStack> drops = NonNullList.create();
this.getDrops(drops, world, pos, state, 0);
boolean deductedSeedSize = false;
for(ItemStack drop : drops){
if(StackUtil.isValid(drop)){
if(drop.getItem() == this.seedItem && !deductedSeedSize){
for (ItemStack drop : drops) {
if (StackUtil.isValid(drop)) {
if (drop.getItem() == this.seedItem && !deductedSeedSize) {
drop.shrink(1);
deductedSeedSize = true;
}
if(StackUtil.isValid(drop)){
EntityItem entity = new EntityItem(world, pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, drop);
if (StackUtil.isValid(drop)) {
EntityItem entity = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, drop);
world.spawnEntity(entity);
}
}
@ -119,24 +119,23 @@ public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarit
}
@Override
public Item getSeed(){
public Item getSeed() {
return this.seedItem;
}
@Override
public int quantityDropped(IBlockState state, int fortune, Random random){
return this.getMetaFromState(state) >= 7 ? random.nextInt(this.addDropAmount)+this.minDropAmount : super.quantityDropped(state, fortune, random);
public int quantityDropped(IBlockState state, int fortune, Random random) {
return this.getMetaFromState(state) >= 7 ? random.nextInt(this.addDropAmount) + this.minDropAmount : super.quantityDropped(state, fortune, random);
}
@Override
public Item getCrop(){
public Item getCrop() {
return this.returnItem;
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int par3){
public Item getItemDropped(IBlockState state, Random rand, int par3) {
return this.getMetaFromState(state) >= 7 ? this.getCrop() : this.getSeed();
}
}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.blocks.base;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.render.IHasModel;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
@ -20,15 +19,15 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
public class BlockStair extends BlockStairs implements ItemBlockBase.ICustomRarity, IHasModel{
public class BlockStair extends BlockStairs implements ItemBlockBase.ICustomRarity, IHasModel {
private final String name;
public BlockStair(Block block, String name){
public BlockStair(Block block, String name) {
this(block.getDefaultState(), name);
}
public BlockStair(IBlockState state, String name){
public BlockStair(IBlockState state, String name) {
super(state);
this.name = name;
this.setLightOpacity(0);
@ -36,29 +35,29 @@ public class BlockStair extends BlockStairs implements ItemBlockBase.ICustomRari
this.register();
}
private void register(){
private void register() {
ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
}
protected String getBaseName(){
protected String getBaseName() {
return this.name;
}
protected ItemBlockBase getItemBlock(){
protected ItemBlockBase getItemBlock() {
return new ItemBlockBase(this);
}
public boolean shouldAddCreative(){
public boolean shouldAddCreative() {
return true;
}
@Override
public void registerRendering(){
public void registerRendering() {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack){
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.COMMON;
}
}

View file

@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.blocks.metalists;
import net.minecraft.util.IStringSerializable;
public enum TheColoredLampColors implements IStringSerializable{
public enum TheColoredLampColors implements IStringSerializable {
WHITE("White", "white"),
ORANGE("Orange", "orange"),
@ -34,20 +34,18 @@ public enum TheColoredLampColors implements IStringSerializable{
public final String regName;
public final String oreName;
TheColoredLampColors(String oreName, String regName){
TheColoredLampColors(String oreName, String regName) {
this.oreName = oreName;
this.regName = regName;
}
public static TheColoredLampColors getColorFromDyeName(String color){
if(color.substring(0, 3).equals("dye")){
public static TheColoredLampColors getColorFromDyeName(String color) {
if (color.substring(0, 3).equals("dye")) {
String actualName = color.substring(3);
for(int i = 0; i < values().length; i++){
for (int i = 0; i < values().length; i++) {
String aName = values()[i].oreName;
if(aName != null){
if(aName.equalsIgnoreCase(actualName)){
return values()[i];
}
if (aName != null) {
if (aName.equalsIgnoreCase(actualName)) { return values()[i]; }
}
}
}
@ -55,7 +53,7 @@ public enum TheColoredLampColors implements IStringSerializable{
}
@Override
public String getName(){
public String getName() {
return this.regName;
}
}

View file

@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.blocks.metalists;
import net.minecraft.item.EnumRarity;
import net.minecraft.util.IStringSerializable;
public enum TheMiscBlocks implements IStringSerializable{
public enum TheMiscBlocks implements IStringSerializable {
QUARTZ_PILLAR("black_quartz_pillar", EnumRarity.RARE),
QUARTZ_CHISELED("black_quartz_chiseled", EnumRarity.RARE),
@ -29,13 +29,13 @@ public enum TheMiscBlocks implements IStringSerializable{
public final String name;
public final EnumRarity rarity;
TheMiscBlocks(String name, EnumRarity rarity){
TheMiscBlocks(String name, EnumRarity rarity) {
this.name = name;
this.rarity = rarity;
}
@Override
public String getName(){
public String getName() {
return this.name;
}
}

View file

@ -1,6 +1,6 @@
package de.ellpeck.actuallyadditions.mod.blocks.render;
public interface IHasModel{
public interface IHasModel {
public void registerRendering();

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.blocks.render;
import java.text.NumberFormat;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.items.ItemBattery;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox;
@ -26,21 +28,17 @@ import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.text.NumberFormat;
@SideOnly(Side.CLIENT)
public class RenderBatteryBox extends TileEntitySpecialRenderer<TileEntityBatteryBox>{
public class RenderBatteryBox extends TileEntitySpecialRenderer<TileEntityBatteryBox> {
@Override
public void render(TileEntityBatteryBox tile, double x, double y, double z, float par5, int par6, float f){
if(!(tile instanceof TileEntityBatteryBox)){
return;
}
public void render(TileEntityBatteryBox tile, double x, double y, double z, float par5, int par6, float f) {
if (!(tile instanceof TileEntityBatteryBox)) { return; }
ItemStack stack = tile.inv.getStackInSlot(0);
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery){
if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery) {
GlStateManager.pushMatrix();
GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F);
GlStateManager.translate((float) x + 0.5F, (float) y + 1F, (float) z + 0.5F);
GlStateManager.pushMatrix();
@ -48,17 +46,17 @@ public class RenderBatteryBox extends TileEntitySpecialRenderer<TileEntityBatter
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.translate(0F, 0F, -50F);
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) {
IEnergyStorage cap = stack.getCapability(CapabilityEnergy.ENERGY, null);
NumberFormat format = NumberFormat.getInstance();
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
String s = format.format(cap.getEnergyStored())+"/"+format.format(cap.getMaxEnergyStored());
float lengthS = -font.getStringWidth(s)/2F;
String s = format.format(cap.getEnergyStored()) + "/" + format.format(cap.getMaxEnergyStored());
float lengthS = -font.getStringWidth(s) / 2F;
String s2 = "Crystal Flux";
float lengthS2 = -font.getStringWidth(s2)/2F;
float lengthS2 = -font.getStringWidth(s2) / 2F;
for(int i = 0; i < 4; i++){
for (int i = 0; i < 4; i++) {
font.drawString(s, lengthS, 10F, 0xFFFFFF, false);
font.drawString(s2, lengthS2, 20F, 0xFFFFFF, false);
@ -69,17 +67,16 @@ public class RenderBatteryBox extends TileEntitySpecialRenderer<TileEntityBatter
GlStateManager.popMatrix();
double boop = Minecraft.getSystemTime()/800D;
GlStateManager.translate(0D, Math.sin(boop%(2*Math.PI))*0.065, 0D);
GlStateManager.rotate((float)(boop*40D%360), 0, 1, 0);
double boop = Minecraft.getSystemTime() / 800D;
GlStateManager.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0);
float scale = stack.getItem() instanceof ItemBlock ? 0.85F : 0.65F;
GlStateManager.scale(scale, scale, scale);
try{
try {
AssetUtil.renderItemInWorld(stack);
}
catch(Exception e){
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in a battery box! The item is "+stack.getItem().getRegistryName()+"!", e);
} catch (Exception e) {
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in a battery box! The item is " + stack.getItem().getRegistryName() + "!", e);
}
GlStateManager.popMatrix();

View file

@ -23,30 +23,27 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderDisplayStand extends TileEntitySpecialRenderer<TileEntityDisplayStand>{
public class RenderDisplayStand extends TileEntitySpecialRenderer<TileEntityDisplayStand> {
@Override
public void render(TileEntityDisplayStand tile, double x, double y, double z, float par5, int par6, float f){
if(!(tile instanceof TileEntityDisplayStand)){
return;
}
public void render(TileEntityDisplayStand tile, double x, double y, double z, float par5, int par6, float f) {
if (!(tile instanceof TileEntityDisplayStand)) { return; }
ItemStack stack = tile.inv.getStackInSlot(0);
if(StackUtil.isValid(stack)){
if (StackUtil.isValid(stack)) {
GlStateManager.pushMatrix();
GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F);
GlStateManager.translate((float) x + 0.5F, (float) y + 1F, (float) z + 0.5F);
double boop = Minecraft.getSystemTime()/800D;
GlStateManager.translate(0D, Math.sin(boop%(2*Math.PI))*0.065, 0D);
GlStateManager.rotate((float)(boop*40D%360), 0, 1, 0);
double boop = Minecraft.getSystemTime() / 800D;
GlStateManager.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0);
float scale = stack.getItem() instanceof ItemBlock ? 0.85F : 0.65F;
GlStateManager.scale(scale, scale, scale);
try{
try {
AssetUtil.renderItemInWorld(stack);
}
catch(Exception e){
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in a display stand! The item is "+stack.getItem().getRegistryName()+"!", e);
} catch (Exception e) {
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in a display stand! The item is " + stack.getItem().getRegistryName() + "!", e);
}
GlStateManager.popMatrix();

View file

@ -27,29 +27,26 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderEmpowerer extends TileEntitySpecialRenderer<TileEntityEmpowerer>{
public class RenderEmpowerer extends TileEntitySpecialRenderer<TileEntityEmpowerer> {
@Override
public void render(TileEntityEmpowerer tile, double x, double y, double z, float par5, int par6, float f){
if(!(tile instanceof TileEntityEmpowerer)){
return;
}
public void render(TileEntityEmpowerer tile, double x, double y, double z, float par5, int par6, float f) {
if (!(tile instanceof TileEntityEmpowerer)) { return; }
ItemStack stack = tile.inv.getStackInSlot(0);
if(StackUtil.isValid(stack)){
if (StackUtil.isValid(stack)) {
GlStateManager.pushMatrix();
GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F);
GlStateManager.translate((float) x + 0.5F, (float) y + 1F, (float) z + 0.5F);
double boop = Minecraft.getSystemTime()/800D;
GlStateManager.translate(0D, Math.sin(boop%(2*Math.PI))*0.065, 0D);
GlStateManager.rotate((float)(boop*40D%360), 0, 1, 0);
double boop = Minecraft.getSystemTime() / 800D;
GlStateManager.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D);
GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0);
float scale = stack.getItem() instanceof ItemBlock ? 0.85F : 0.65F;
GlStateManager.scale(scale, scale, scale);
try{
try {
AssetUtil.renderItemInWorld(stack);
}
catch(Exception e){
} catch (Exception e) {
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in an empowerer! The item is " + stack.getItem().getRegistryName() + ":" + stack.getMetadata() + "!", e);
}
@ -57,14 +54,14 @@ public class RenderEmpowerer extends TileEntitySpecialRenderer<TileEntityEmpower
}
int index = tile.recipeForRenderIndex;
if(index >= 0 && ActuallyAdditionsAPI.EMPOWERER_RECIPES.size() > index){
if (index >= 0 && ActuallyAdditionsAPI.EMPOWERER_RECIPES.size() > index) {
EmpowererRecipe recipe = ActuallyAdditionsAPI.EMPOWERER_RECIPES.get(index);
if(recipe != null){
for(int i = 0; i < EnumFacing.HORIZONTALS.length; i++){
if (recipe != null) {
for (int i = 0; i < EnumFacing.HORIZONTALS.length; i++) {
EnumFacing facing = EnumFacing.HORIZONTALS[i];
BlockPos offset = tile.getPos().offset(facing, 3);
AssetUtil.renderLaser(tile.getPos().getX()+0.5, tile.getPos().getY()+0.5, tile.getPos().getZ()+0.5, offset.getX()+0.5, offset.getY()+0.95, offset.getZ()+0.5, 80, 1F, 0.1F, recipe.getParticleColors());
AssetUtil.renderLaser(tile.getPos().getX() + 0.5, tile.getPos().getY() + 0.5, tile.getPos().getZ() + 0.5, offset.getX() + 0.5, offset.getY() + 0.95, offset.getZ() + 0.5, 80, 1F, 0.1F, recipe.getParticleColors());
}
}
}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.blocks.render;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
import de.ellpeck.actuallyadditions.api.laser.LaserType;
@ -33,16 +32,16 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderLaserRelay extends TileEntitySpecialRenderer<TileEntityLaserRelay>{
public class RenderLaserRelay extends TileEntitySpecialRenderer<TileEntityLaserRelay> {
private static final float[] COLOR = new float[]{1F, 0F, 0F};
private static final float[] COLOR_ITEM = new float[]{0F, 124F/255F, 16F/255F};
private static final float[] COLOR_FLUIDS = new float[]{0F, 97F/255F, 198F/255F};
private static final float[] COLOR_INFRARED = new float[]{209F/255F, 179F/255F, 239F/255F};
private static final float[] COLOR = new float[] { 1F, 0F, 0F };
private static final float[] COLOR_ITEM = new float[] { 0F, 124F / 255F, 16F / 255F };
private static final float[] COLOR_FLUIDS = new float[] { 0F, 97F / 255F, 198F / 255F };
private static final float[] COLOR_INFRARED = new float[] { 209F / 255F, 179F / 255F, 239F / 255F };
@Override
public void render(TileEntityLaserRelay tile, double x, double y, double z, float par5, int par6, float f){
if(tile instanceof TileEntityLaserRelay){
public void render(TileEntityLaserRelay tile, double x, double y, double z, float par5, int par6, float f) {
if (tile instanceof TileEntityLaserRelay) {
TileEntityLaserRelay relay = tile;
boolean hasInvis = false;
@ -50,21 +49,21 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer<TileEntityLaserR
boolean hasGoggles = ItemEngineerGoggles.isWearing(player);
ItemStack upgrade = relay.inv.getStackInSlot(0);
if(StackUtil.isValid(upgrade)){
if(upgrade.getItem() == InitItems.itemLaserUpgradeInvisibility){
if (StackUtil.isValid(upgrade)) {
if (upgrade.getItem() == InitItems.itemLaserUpgradeInvisibility) {
hasInvis = true;
}
ItemStack hand = player.getHeldItemMainhand();
if(hasGoggles || StackUtil.isValid(hand) && (hand.getItem() == ConfigValues.itemCompassConfigurator || hand.getItem() instanceof ItemLaserWrench) || "themattabase".equals(player.getName())){
if (hasGoggles || StackUtil.isValid(hand) && (hand.getItem() == ConfigValues.itemCompassConfigurator || hand.getItem() instanceof ItemLaserWrench) || "themattabase".equals(player.getName())) {
GlStateManager.pushMatrix();
float yTrans = tile.getBlockMetadata() == 0 ? 0.2F : 0.8F;
GlStateManager.translate((float)x+0.5F, (float)y+yTrans, (float)z+0.5F);
GlStateManager.translate((float) x + 0.5F, (float) y + yTrans, (float) z + 0.5F);
GlStateManager.scale(0.2F, 0.2F, 0.2F);
double boop = Minecraft.getSystemTime()/800D;
GlStateManager.rotate((float)(boop*40D%360), 0, 1, 0);
double boop = Minecraft.getSystemTime() / 800D;
GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0);
AssetUtil.renderItemInWorld(upgrade);
@ -73,21 +72,21 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer<TileEntityLaserR
}
ConcurrentSet<IConnectionPair> connections = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(tile.getPos(), tile.getWorld());
if(connections != null && !connections.isEmpty()){
for(IConnectionPair pair : connections){
if(!pair.doesSuppressRender() && tile.getPos().equals(pair.getPositions()[0])){
if (connections != null && !connections.isEmpty()) {
for (IConnectionPair pair : connections) {
if (!pair.doesSuppressRender() && tile.getPos().equals(pair.getPositions()[0])) {
BlockPos first = tile.getPos();
BlockPos second = pair.getPositions()[1];
TileEntity secondTile = tile.getWorld().getTileEntity(second);
if(secondTile instanceof TileEntityLaserRelay){
ItemStack secondUpgrade = ((TileEntityLaserRelay)secondTile).inv.getStackInSlot(0);
if (secondTile instanceof TileEntityLaserRelay) {
ItemStack secondUpgrade = ((TileEntityLaserRelay) secondTile).inv.getStackInSlot(0);
boolean otherInvis = StackUtil.isValid(secondUpgrade) && secondUpgrade.getItem() == InitItems.itemLaserUpgradeInvisibility;
if(hasGoggles || !hasInvis || !otherInvis){
if (hasGoggles || !hasInvis || !otherInvis) {
float[] color = hasInvis && otherInvis ? COLOR_INFRARED : relay.type == LaserType.ITEM ? COLOR_ITEM : relay.type == LaserType.FLUID ? COLOR_FLUIDS : COLOR;
AssetUtil.renderLaser(first.getX()+0.5, first.getY()+0.5, first.getZ()+0.5, second.getX()+0.5, second.getY()+0.5, second.getZ()+0.5, 120, hasInvis && otherInvis ? 0.1F : 0.35F, 0.05, color);
AssetUtil.renderLaser(first.getX() + 0.5, first.getY() + 0.5, first.getZ() + 0.5, second.getX() + 0.5, second.getY() + 0.5, second.getZ() + 0.5, 120, hasInvis && otherInvis ? 0.1F : 0.35F, 0.05, color);
}
}
}
@ -97,7 +96,7 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer<TileEntityLaserR
}
@Override
public boolean isGlobalRenderer(TileEntityLaserRelay tile){
public boolean isGlobalRenderer(TileEntityLaserRelay tile) {
return true;
}
}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.blocks.render;
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
@ -23,43 +22,43 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderReconstructorLens extends TileEntitySpecialRenderer<TileEntityAtomicReconstructor>{
public class RenderReconstructorLens extends TileEntitySpecialRenderer<TileEntityAtomicReconstructor> {
@Override
public void render(TileEntityAtomicReconstructor tile, double x, double y, double z, float par5, int par6, float f){
if(tile == null) return;
public void render(TileEntityAtomicReconstructor tile, double x, double y, double z, float par5, int par6, float f) {
if (tile == null) return;
ItemStack stack = tile.inv.getStackInSlot(0);
if(StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem){
if (StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem) {
GlStateManager.pushMatrix();
GlStateManager.translate((float)x+0.5F, (float)y-0.5F, (float)z+0.5F);
GlStateManager.translate((float) x + 0.5F, (float) y - 0.5F, (float) z + 0.5F);
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
IBlockState state = tile.getWorld().getBlockState(tile.getPos());
int meta = state.getBlock().getMetaFromState(state);
if(meta == 0){
if (meta == 0) {
GlStateManager.translate(0F, -0.5F, 0F);
GlStateManager.rotate(90F, 1F, 0F, 0F);
}
if(meta == 1){
GlStateManager.translate(0F, -1.5F-0.5F/16F, 0F);
if (meta == 1) {
GlStateManager.translate(0F, -1.5F - 0.5F / 16F, 0F);
GlStateManager.rotate(90F, 1F, 0F, 0F);
}
if(meta == 2){
if (meta == 2) {
GlStateManager.translate(0F, -1F, 0F);
GlStateManager.translate(0F, 0F, -0.5F);
}
if(meta == 3){
if (meta == 3) {
GlStateManager.translate(0F, -1F, 0F);
GlStateManager.translate(0F, 0F, 0.5F+0.5F/16F);
GlStateManager.translate(0F, 0F, 0.5F + 0.5F / 16F);
}
if(meta == 4){
if (meta == 4) {
GlStateManager.translate(0F, -1F, 0F);
GlStateManager.translate(0.5F+0.5F/16F, 0F, 0F);
GlStateManager.translate(0.5F + 0.5F / 16F, 0F, 0F);
GlStateManager.rotate(90F, 0F, 1F, 0F);
}
if(meta == 5){
if (meta == 5) {
GlStateManager.translate(0F, -1F, 0F);
GlStateManager.translate(-0.5F, 0F, 0F);
GlStateManager.rotate(90F, 0F, 1F, 0F);

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.blocks.render;
import java.util.Locale;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.misc.cloud.ISmileyCloudEasterEgg;
import de.ellpeck.actuallyadditions.mod.misc.cloud.SmileyCloudEasterEggs;
@ -25,61 +27,58 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Locale;
@SideOnly(Side.CLIENT)
public class RenderSmileyCloud extends TileEntitySpecialRenderer<TileEntitySmileyCloud>{
public class RenderSmileyCloud extends TileEntitySpecialRenderer<TileEntitySmileyCloud> {
@Override
public void render(TileEntitySmileyCloud theCloud, double x, double y, double z, float par5, int partial, float f){
if(theCloud instanceof TileEntitySmileyCloud){
public void render(TileEntitySmileyCloud theCloud, double x, double y, double z, float par5, int partial, float f) {
if (theCloud instanceof TileEntitySmileyCloud) {
GlStateManager.pushMatrix();
GlStateManager.translate((float)x+0.5F, (float)y-0.5F, (float)z+0.5F);
GlStateManager.translate((float) x + 0.5F, (float) y - 0.5F, (float) z + 0.5F);
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
GlStateManager.translate(0.0F, -2F, 0.0F);
if(theCloud.name != null && !theCloud.name.isEmpty()){
if (theCloud.name != null && !theCloud.name.isEmpty()) {
boolean renderedEaster = false;
easterEggs:
for(ISmileyCloudEasterEgg cloud : SmileyCloudEasterEggs.CLOUD_STUFF){
for(String triggerName : cloud.getTriggerNames()){
if(triggerName != null && theCloud.name != null){
if(triggerName.equalsIgnoreCase(theCloud.name)){
GlStateManager.pushMatrix();
easterEggs: for (ISmileyCloudEasterEgg cloud : SmileyCloudEasterEggs.CLOUD_STUFF) {
for (String triggerName : cloud.getTriggerNames()) {
if (triggerName != null && theCloud.name != null) {
if (triggerName.equalsIgnoreCase(theCloud.name)) {
GlStateManager.pushMatrix();
IBlockState state = theCloud.getWorld().getBlockState(theCloud.getPos());
if(state.getBlock() == InitBlocks.blockSmileyCloud){
switch(state.getValue(BlockHorizontal.FACING)){
case NORTH:
GlStateManager.rotate(180, 0, 1, 0);
break;
case EAST:
GlStateManager.rotate(270, 0, 1, 0);
break;
case WEST:
GlStateManager.rotate(90, 0, 1, 0);
break;
default:
break;
}
IBlockState state = theCloud.getWorld().getBlockState(theCloud.getPos());
if (state.getBlock() == InitBlocks.blockSmileyCloud) {
switch (state.getValue(BlockHorizontal.FACING)) {
case NORTH:
GlStateManager.rotate(180, 0, 1, 0);
break;
case EAST:
GlStateManager.rotate(270, 0, 1, 0);
break;
case WEST:
GlStateManager.rotate(90, 0, 1, 0);
break;
default:
break;
}
cloud.renderExtra(0.0625F);
GlStateManager.popMatrix();
renderedEaster = true;
break easterEggs;
}
cloud.renderExtra(0.0625F);
GlStateManager.popMatrix();
renderedEaster = true;
break easterEggs;
}
}
}
}
String nameLower = theCloud.name.toLowerCase(Locale.ROOT);
if(SpecialRenderInit.SPECIAL_LIST.containsKey(nameLower)){
if (SpecialRenderInit.SPECIAL_LIST.containsKey(nameLower)) {
RenderSpecial render = SpecialRenderInit.SPECIAL_LIST.get(nameLower);
if(render != null){
if (render != null) {
GlStateManager.pushMatrix();
GlStateManager.translate(0F, renderedEaster ? 0.05F : 0.25F, 0F);
GlStateManager.rotate(180F, 1.0F, 0.0F, 1.0F);
@ -92,9 +91,9 @@ public class RenderSmileyCloud extends TileEntitySpecialRenderer<TileEntitySmile
GlStateManager.popMatrix();
Minecraft mc = Minecraft.getMinecraft();
if(theCloud.name != null && !theCloud.name.isEmpty() && !mc.gameSettings.hideGUI){
if(mc.player.getDistanceSq(theCloud.getPos()) <= 36){
AssetUtil.renderNameTag(theCloud.name, x+0.5F, y+1.5F, z+0.5F);
if (theCloud.name != null && !theCloud.name.isEmpty() && !mc.gameSettings.hideGUI) {
if (mc.player.getDistanceSq(theCloud.getPos()) <= 36) {
AssetUtil.renderNameTag(theCloud.name, x + 0.5F, y + 1.5F, z + 0.5F);
}
}
}

View file

@ -91,11 +91,11 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
public final class InitBooklet{
public final class InitBooklet {
public static BookletChapter[] chaptersIntroduction = new BookletChapter[11];
public static void preInit(){
public static void preInit() {
ActuallyAdditionsAPI.entryAllAndSearch = new BookletEntryAllItems("allAndSearch").setImportant();
ActuallyAdditionsAPI.entryTrials = new BookletEntryTrials("trials");
@ -111,19 +111,19 @@ public final class InitBooklet{
ActuallyAdditionsAPI.entryUpdatesAndInfos = new BookletEntry("updatesAndInfos").setSpecial();
}
public static void postInit(){
public static void postInit() {
initChapters();
int chapCount = 0;
int pageCount = 0;
int infoCount = 0;
for(IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES){
for(IBookletChapter chapter : entry.getAllChapters()){
if(!ActuallyAdditionsAPI.ALL_CHAPTERS.contains(chapter)){
for (IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES) {
for (IBookletChapter chapter : entry.getAllChapters()) {
if (!ActuallyAdditionsAPI.ALL_CHAPTERS.contains(chapter)) {
ActuallyAdditionsAPI.ALL_CHAPTERS.add(chapter);
chapCount++;
for(IBookletPage page : chapter.getAllPages()){
for (IBookletPage page : chapter.getAllPages()) {
pageCount++;
List<ItemStack> items = new ArrayList<>();
@ -131,8 +131,8 @@ public final class InitBooklet{
List<FluidStack> fluids = new ArrayList<>();
page.getFluidStacksForPage(fluids);
if(items != null && !items.isEmpty() || fluids != null && !fluids.isEmpty()){
if(!ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.contains(page)){
if (items != null && !items.isEmpty() || fluids != null && !fluids.isEmpty()) {
if (!ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.contains(page)) {
ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.add(page);
infoCount++;
}
@ -158,31 +158,31 @@ public final class InitBooklet{
return prio2.compareTo(prio1);
});
ActuallyAdditions.LOGGER.info("Registered a total of "+chapCount+" booklet chapters, where "+infoCount+" out of "+pageCount+" booklet pages contain information about items or fluids!");
ActuallyAdditions.LOGGER.info("Registered a total of " + chapCount + " booklet chapters, where " + infoCount + " out of " + pageCount + " booklet pages contain information about items or fluids!");
}
private static void initChapters(){
private static void initChapters() {
//Getting Started
chaptersIntroduction[0] = new BookletChapter("bookTutorial", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemBooklet), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3), new PageCrafting(4, ItemCrafting.recipeBook).setNoText());
chaptersIntroduction[1] = new BookletChapter("videoGuide", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.YOUTUBE_ICON.ordinal()), new PageLinkButton(1, "https://www.youtube.com/watch?v=fhjz0Ew56pM"), new PageLinkButton(2, "https://www.youtube.com/playlist?list=PLJeFZ64pT89MrTRZYzD_rtHFajPVlt6cF")).setImportant();
new BookletChapter("intro", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemBooklet), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3));
ArrayList<BookletPage> crystalPages = new ArrayList<>();
crystalPages.addAll(Arrays.asList(new PageTextOnly(1).addTextReplacement("<rf>", TileEntityAtomicReconstructor.ENERGY_USE), new PageTextOnly(2), new PageTextOnly(3), new PagePicture(4, "page_atomic_reconstructor", 0).setNoText(), new PageTextOnly(5), new PageCrafting(6, BlockCrafting.recipeAtomicReconstructor).setWildcard()));
for(int i = 0; i < LensRecipeHandler.MAIN_PAGE_RECIPES.size(); i++){
crystalPages.add(new PageReconstructor(7+i, LensRecipeHandler.MAIN_PAGE_RECIPES.get(i)).setNoText());
for (int i = 0; i < LensRecipeHandler.MAIN_PAGE_RECIPES.size(); i++) {
crystalPages.add(new PageReconstructor(7 + i, LensRecipeHandler.MAIN_PAGE_RECIPES.get(i)).setNoText());
}
crystalPages.add(new PageCrafting(crystalPages.size()+1, MiscCrafting.RECIPES_CRYSTALS).setNoText());
crystalPages.add(new PageCrafting(crystalPages.size()+1, MiscCrafting.RECIPES_CRYSTAL_BLOCKS).setNoText());
crystalPages.add(new PageCrafting(crystalPages.size() + 1, MiscCrafting.RECIPES_CRYSTALS).setNoText());
crystalPages.add(new PageCrafting(crystalPages.size() + 1, MiscCrafting.RECIPES_CRYSTAL_BLOCKS).setNoText());
chaptersIntroduction[2] = new BookletChapter("engineerHouse", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(Items.EMERALD), new PageTextOnly(1), new PagePicture(2, "page_engineer_house", 145));
chaptersIntroduction[6] = new BookletChapter("crystals", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockAtomicReconstructor), crystalPages.toArray(new BookletPage[crystalPages.size()])).setSpecial();
chaptersIntroduction[5] = new BookletChapter("coalGen", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockCoalGenerator), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityCoalGenerator.PRODUCE), new PageCrafting(2, BlockCrafting.recipeCoalGen).setWildcard().setNoText());
ArrayList<BookletPage> empowererPages = new ArrayList<>();
empowererPages.addAll(Arrays.asList(new PageTextOnly(1), new PagePicture(2, "page_empowerer", 137), new PageCrafting(3, BlockCrafting.recipeEmpowerer), new PageCrafting(4, BlockCrafting.recipeDisplayStand)));
for(int i = 0; i < EmpowererHandler.MAIN_PAGE_RECIPES.size(); i++){
empowererPages.add(new PageEmpowerer(7+i, EmpowererHandler.MAIN_PAGE_RECIPES.get(i)).setNoText());
for (int i = 0; i < EmpowererHandler.MAIN_PAGE_RECIPES.size(); i++) {
empowererPages.add(new PageEmpowerer(7 + i, EmpowererHandler.MAIN_PAGE_RECIPES.get(i)).setNoText());
}
empowererPages.add(new PageCrafting(empowererPages.size()+1, MiscCrafting.RECIPES_EMPOWERED_CRYSTALS).setNoText());
empowererPages.add(new PageCrafting(empowererPages.size()+1, MiscCrafting.RECIPES_EMPOWERED_CRYSTAL_BLOCKS).setNoText());
empowererPages.add(new PageCrafting(empowererPages.size() + 1, MiscCrafting.RECIPES_EMPOWERED_CRYSTALS).setNoText());
empowererPages.add(new PageCrafting(empowererPages.size() + 1, MiscCrafting.RECIPES_EMPOWERED_CRYSTAL_BLOCKS).setNoText());
new BookletChapter("empowerer", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockEmpowerer), empowererPages.toArray(new BookletPage[empowererPages.size()])).setSpecial();
new BookletChapter("craftingIngs", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeCoil).setNoText(), new PageCrafting(3, ItemCrafting.recipeCoilAdvanced).setNoText(), new PageCrafting(4, BlockCrafting.recipeCase).setNoText(), new PageCrafting(5, BlockCrafting.recipeEnderPearlBlock).setNoText(), new PageCrafting(6, BlockCrafting.recipeEnderCase).setNoText(), new PageCrafting(7, ItemCrafting.recipeRing).setNoText(), new PageCrafting(8, ItemCrafting.recipeKnifeHandle).setNoText(), new PageCrafting(9, ItemCrafting.recipeKnifeBlade).setNoText(), new PageCrafting(10, ItemCrafting.recipeKnife).setNoText(), new PageCrafting(11, ItemCrafting.recipeDough).setNoText(), new PageCrafting(12, ItemCrafting.recipeRiceDough).setNoText(), new PageCrafting(13, BlockCrafting.recipeIronCase).setNoText(), new PageCrafting(14, ItemCrafting.recipeLens).setNoText());
chaptersIntroduction[4] = new BookletChapter("rf", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(Items.REDSTONE), new PageTextOnly(1), new PageTextOnly(2)).setImportant();
@ -197,11 +197,11 @@ public final class InitBooklet{
new BookletChapter("cloud", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockSmileyCloud), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud).setWildcard()).setSpecial();
new BookletChapter("coalStuff", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_COAL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeTinyCoal).setNoText(), new PageCrafting(3, ItemCrafting.recipeTinyChar).setNoText(), new PageCrafting(4, BlockCrafting.recipeBlockChar).setNoText());
ArrayList<BookletPage> lampPages = new ArrayList<>();
lampPages.add(new PageTextOnly(lampPages.size()+1));
lampPages.add(new PageTextOnly(lampPages.size()+1));
lampPages.add(new PageCrafting(lampPages.size()+1, BlockCrafting.recipePowerer).setWildcard().setNoText());
for(IRecipe recipe : BlockCrafting.RECIPES_LAMPS){
lampPages.add(new PageCrafting(lampPages.size()+1, recipe).setNoText());
lampPages.add(new PageTextOnly(lampPages.size() + 1));
lampPages.add(new PageTextOnly(lampPages.size() + 1));
lampPages.add(new PageCrafting(lampPages.size() + 1, BlockCrafting.recipePowerer).setWildcard().setNoText());
for (IRecipe recipe : BlockCrafting.RECIPES_LAMPS) {
lampPages.add(new PageCrafting(lampPages.size() + 1, recipe).setNoText());
}
new BookletChapter("lamps", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockColoredLampOn, 1, TheColoredLampColors.GREEN.ordinal()), lampPages.toArray(new BookletPage[lampPages.size()]));
new BookletChapter("enderStar", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.ENDER_STAR.ordinal()), new PageCrafting(1, ItemCrafting.recipeEnderStar));
@ -260,9 +260,9 @@ public final class InitBooklet{
list.add(new PageTextOnly(1).addTextReplacement("<rf>", TileEntityGrinder.ENERGY_USE));
list.add(new PageCrafting(2, BlockCrafting.recipeCrusher).setWildcard().setNoText());
list.add(new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setWildcard().setNoText());
if(CrusherCrafting.recipeIronHorseArmor != null) list.add(new PageCrusherRecipe(4, CrusherCrafting.recipeIronHorseArmor).setNoText());
if(CrusherCrafting.recipeGoldHorseArmor != null) list.add(new PageCrusherRecipe(5, CrusherCrafting.recipeGoldHorseArmor).setNoText());
if(CrusherCrafting.recipeDiamondHorseArmor != null) list.add(new PageCrusherRecipe(6, CrusherCrafting.recipeDiamondHorseArmor).setNoText());
if (CrusherCrafting.recipeIronHorseArmor != null) list.add(new PageCrusherRecipe(4, CrusherCrafting.recipeIronHorseArmor).setNoText());
if (CrusherCrafting.recipeGoldHorseArmor != null) list.add(new PageCrusherRecipe(5, CrusherCrafting.recipeGoldHorseArmor).setNoText());
if (CrusherCrafting.recipeDiamondHorseArmor != null) list.add(new PageCrusherRecipe(6, CrusherCrafting.recipeDiamondHorseArmor).setNoText());
new BookletChapterCrusher("crusher", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockGrinderDouble), list.toArray(new IBookletPage[0]));
new BookletChapter("furnaceDouble", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockFurnaceDouble), new PageCrafting(1, BlockCrafting.recipeFurnace).setWildcard().addTextReplacement("<rf>", TileEntityFurnaceDouble.ENERGY_USE));
@ -284,23 +284,23 @@ public final class InitBooklet{
//No RF Using Items
chaptersIntroduction[9] = new BookletChapter("goggles", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemEngineerGoggles), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeGoggles).setNoText(), new PageCrafting(3, ItemCrafting.recipeGogglesAdvanced).setNoText()).setImportant();
new BookletChapter("bags", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemBag), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeBag), new PageCrafting(3, ItemCrafting.recipeVoidBag).setNoText()).setImportant();
new BookletChapter("wings", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemWingsOfTheBats), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BAT_WING.ordinal())).addTextReplacement("<secs>", ItemWingsOfTheBats.MAX_FLY_TIME/20), new PageCrafting(2, ItemCrafting.recipeWings).setNoText()).setSpecial();
new BookletChapter("wings", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemWingsOfTheBats), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BAT_WING.ordinal())).addTextReplacement("<secs>", ItemWingsOfTheBats.MAX_FLY_TIME / 20), new PageCrafting(2, ItemCrafting.recipeWings).setNoText()).setSpecial();
new BookletChapter("foods", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemFoods, 1, TheFoods.HAMBURGER.ordinal()), new PageCrafting(1, FoodCrafting.recipeBacon).setNoText(), new PageFurnace(2, new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE_BREAD.ordinal())).setNoText(), new PageCrafting(3, FoodCrafting.recipeHamburger).setNoText(), new PageCrafting(4, FoodCrafting.recipeBigCookie).setNoText(), new PageCrafting(5, FoodCrafting.recipeSubSandwich).setNoText(), new PageCrafting(6, FoodCrafting.recipeFrenchFry).setNoText(), new PageCrafting(7, FoodCrafting.recipeFrenchFries).setNoText(), new PageCrafting(8, FoodCrafting.recipeFishNChips).setNoText(), new PageCrafting(9, FoodCrafting.recipeCheese).setNoText(), new PageCrafting(10, FoodCrafting.recipePumpkinStew).setNoText(), new PageCrafting(11, FoodCrafting.recipeCarrotJuice).setNoText(), new PageCrafting(12, FoodCrafting.recipeSpaghetti).setNoText(), new PageCrafting(13, FoodCrafting.recipeNoodle).setNoText(), new PageCrafting(14, FoodCrafting.recipeChocolate).setNoText(), new PageCrafting(15, FoodCrafting.recipeChocolateCake).setNoText(), new PageCrafting(16, FoodCrafting.recipeToast).setNoText(), new PageFurnace(17, new ItemStack(InitItems.itemFoods, 1, TheFoods.BAGUETTE.ordinal())).setNoText(), new PageCrafting(18, FoodCrafting.recipeChocolateToast).setNoText(), new PageCrafting(1, FoodCrafting.recipePizza).setNoText());
new BookletChapter("leafBlower", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemLeafBlowerAdvanced), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLeafBlower).setNoText(), new PageCrafting(3, ItemCrafting.recipeLeafBlowerAdvanced).setNoText()).setImportant();
new BookletChapter("playerProbe", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemPlayerProbe), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipePlayerProbe).setNoText()).setSpecial();
ArrayList<BookletPage> aiotPages = new ArrayList<>();
aiotPages.add(new PageTextOnly(aiotPages.size()+1));
for(IRecipe recipe : ToolCrafting.RECIPES_PAXELS){
aiotPages.add(new PageCrafting(aiotPages.size()+1, recipe).setWildcard().setNoText());
aiotPages.add(new PageTextOnly(aiotPages.size() + 1));
for (IRecipe recipe : ToolCrafting.RECIPES_PAXELS) {
aiotPages.add(new PageCrafting(aiotPages.size() + 1, recipe).setWildcard().setNoText());
}
new BookletChapter("aiots", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.emeraldPaxel), aiotPages.toArray(new BookletPage[aiotPages.size()])).setImportant();
new BookletChapter("jams", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemJams), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemJams, 1, Util.WILDCARD)), new PagePicture(2, "page_jam_house", 150), new PageTextOnly(3));
ArrayList<BookletPage> potionRingPages = new ArrayList<>();
potionRingPages.add(new PageTextOnly(potionRingPages.size()+1));
for(IRecipe recipe : ItemCrafting.RECIPES_POTION_RINGS){
potionRingPages.add(new PageCrafting(potionRingPages.size()+1, recipe).setNoText());
potionRingPages.add(new PageTextOnly(potionRingPages.size() + 1));
for (IRecipe recipe : ItemCrafting.RECIPES_POTION_RINGS) {
potionRingPages.add(new PageCrafting(potionRingPages.size() + 1, recipe).setNoText());
}
new BookletChapter("potionRings", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemPotionRing), potionRingPages.toArray(new BookletPage[potionRingPages.size()]));
new BookletChapter("spawnerChanger", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemSpawnerChanger), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeSpawnerChanger).setNoText());

View file

@ -10,6 +10,9 @@
package de.ellpeck.actuallyadditions.mod.booklet.button;
import java.util.ArrayList;
import java.util.List;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
@ -29,45 +32,40 @@ import net.minecraftforge.fml.client.config.GuiUtils;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
@SideOnly(Side.CLIENT)
public class BookmarkButton extends GuiButton{
public class BookmarkButton extends GuiButton {
private final GuiBooklet booklet;
public IBookletPage assignedPage;
public BookmarkButton(int id, int x, int y, GuiBooklet booklet){
public BookmarkButton(int id, int x, int y, GuiBooklet booklet) {
super(id, x, y, 16, 16, "");
this.booklet = booklet;
}
public void onPressed(){
if(this.assignedPage != null){
if(GuiScreen.isShiftKeyDown()){
public void onPressed() {
if (this.assignedPage != null) {
if (GuiScreen.isShiftKeyDown()) {
this.assignedPage = null;
}
else if(!(this.booklet instanceof GuiPage) || ((GuiPage)this.booklet).pages[0] != this.assignedPage){
} else if (!(this.booklet instanceof GuiPage) || ((GuiPage) this.booklet).pages[0] != this.assignedPage) {
GuiPage gui = BookletUtils.createPageGui(this.booklet.previousScreen, this.booklet, this.assignedPage);
Minecraft.getMinecraft().displayGuiScreen(gui);
}
}
else{
if(this.booklet instanceof GuiPage){
this.assignedPage = ((GuiPage)this.booklet).pages[0];
} else {
if (this.booklet instanceof GuiPage) {
this.assignedPage = ((GuiPage) this.booklet).pages[0];
}
}
}
@Override
public void drawButton(Minecraft minecraft, int x, int y, float f){
if(this.visible){
public void drawButton(Minecraft minecraft, int x, int y, float f) {
if (this.visible) {
minecraft.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = x >= this.x && y >= this.y && x < this.x+this.width && y < this.y+this.height;
this.hovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height;
int k = this.getHoverState(this.hovered);
if(k == 0){
if (k == 0) {
k = 1;
}
@ -75,39 +73,37 @@ public class BookmarkButton extends GuiButton{
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.blendFunc(770, 771);
int renderHeight = 25;
this.drawTexturedModalRect(this.x, this.y, 224+(this.assignedPage == null ? 0 : 16), 14-renderHeight+k*renderHeight, this.width, renderHeight);
this.drawTexturedModalRect(this.x, this.y, 224 + (this.assignedPage == null ? 0 : 16), 14 - renderHeight + k * renderHeight, this.width, renderHeight);
this.mouseDragged(minecraft, x, y);
if(this.assignedPage != null){
if (this.assignedPage != null) {
ItemStack display = this.assignedPage.getChapter().getDisplayItemStack();
if(StackUtil.isValid(display)){
if (StackUtil.isValid(display)) {
GlStateManager.pushMatrix();
AssetUtil.renderStackToGui(display, this.x+2, this.y+1, 0.725F);
AssetUtil.renderStackToGui(display, this.x + 2, this.y + 1, 0.725F);
GlStateManager.popMatrix();
}
}
}
}
public void drawHover(int mouseX, int mouseY){
if(this.isMouseOver()){
public void drawHover(int mouseX, int mouseY) {
if (this.isMouseOver()) {
List<String> list = new ArrayList<>();
if(this.assignedPage != null){
if (this.assignedPage != null) {
IBookletChapter chapter = this.assignedPage.getChapter();
list.add(TextFormatting.GOLD+chapter.getLocalizedName()+", Page "+(chapter.getPageIndex(this.assignedPage)+1));
list.add(StringUtil.localize("booklet."+ActuallyAdditions.MODID+".bookmarkButton.bookmark.openDesc"));
list.add(TextFormatting.ITALIC+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".bookmarkButton.bookmark.removeDesc"));
}
else{
list.add(TextFormatting.GOLD+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".bookmarkButton.noBookmark.name"));
list.add(TextFormatting.GOLD + chapter.getLocalizedName() + ", Page " + (chapter.getPageIndex(this.assignedPage) + 1));
list.add(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.bookmark.openDesc"));
list.add(TextFormatting.ITALIC + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.bookmark.removeDesc"));
} else {
list.add(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.noBookmark.name"));
if(this.booklet instanceof GuiPage){
list.add(StringUtil.localize("booklet."+ActuallyAdditions.MODID+".bookmarkButton.noBookmark.pageDesc"));
}
else{
list.add(StringUtil.localize("booklet."+ActuallyAdditions.MODID+".bookmarkButton.noBookmark.notPageDesc"));
if (this.booklet instanceof GuiPage) {
list.add(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.noBookmark.pageDesc"));
} else {
list.add(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.noBookmark.notPageDesc"));
}
}

View file

@ -22,12 +22,12 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class EntryButton extends GuiButton{
public class EntryButton extends GuiButton {
private final GuiBookletBase gui;
private final ItemStack stackToRender;
public EntryButton(GuiBookletBase gui, int id, int x, int y, int width, int height, String text, ItemStack stackToRender){
public EntryButton(GuiBookletBase gui, int id, int x, int y, int width, int height, String text, ItemStack stackToRender) {
super(id, x, y, width, height, text);
this.gui = gui;
StackUtil.isValid(stackToRender);
@ -35,32 +35,32 @@ public class EntryButton extends GuiButton{
}
@Override
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float f){
if(this.visible){
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float f) {
if (this.visible) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x+this.width && mouseY < this.y+this.height;
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.blendFunc(770, 771);
this.mouseDragged(minecraft, mouseX, mouseY);
int textOffsetX = 0;
if(StackUtil.isValid(this.stackToRender)){
if (StackUtil.isValid(this.stackToRender)) {
GlStateManager.pushMatrix();
AssetUtil.renderStackToGui(this.stackToRender, this.x-4, this.y, 0.725F);
AssetUtil.renderStackToGui(this.stackToRender, this.x - 4, this.y, 0.725F);
GlStateManager.popMatrix();
textOffsetX = 10;
}
float scale = this.gui.getMediumFontSize();
if(this.hovered){
if (this.hovered) {
GlStateManager.pushMatrix();
AssetUtil.drawHorizontalGradientRect(this.x+textOffsetX-1, this.y+this.height-1, this.x+(int)(minecraft.fontRenderer.getStringWidth(this.displayString)*scale)+textOffsetX+1, this.y+this.height, 0x80 << 24 | 22271, 22271, this.zLevel);
AssetUtil.drawHorizontalGradientRect(this.x + textOffsetX - 1, this.y + this.height - 1, this.x + (int) (minecraft.fontRenderer.getStringWidth(this.displayString) * scale) + textOffsetX + 1, this.y + this.height, 0x80 << 24 | 22271, 22271, this.zLevel);
GlStateManager.popMatrix();
}
StringUtil.renderScaledAsciiString(minecraft.fontRenderer, this.displayString, this.x+textOffsetX, this.y+2+(this.height-8)/2, 0, false, scale);
StringUtil.renderScaledAsciiString(minecraft.fontRenderer, this.displayString, this.x + textOffsetX, this.y + 2 + (this.height - 8) / 2, 0, false, scale);
}
}
}

View file

@ -16,36 +16,34 @@ import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
public class TrialsButton extends TexturedButton{
public class TrialsButton extends TexturedButton {
private final boolean isTrials;
public TrialsButton(GuiBooklet gui){
super(GuiBooklet.RES_LOC_GADGETS, -152000, gui.getGuiLeft()+gui.getSizeX(), gui.getGuiTop()+10, 0, 204, 52, 16);
public TrialsButton(GuiBooklet gui) {
super(GuiBooklet.RES_LOC_GADGETS, -152000, gui.getGuiLeft() + gui.getSizeX(), gui.getGuiTop() + 10, 0, 204, 52, 16);
this.isTrials = gui.areTrialsOpened();
this.enabled = !this.isTrials;
}
@Override
public void drawButton(Minecraft minecraft, int x, int y, float f){
public void drawButton(Minecraft minecraft, int x, int y, float f) {
super.drawButton(minecraft, x, y, f);
if(this.visible){
if(this.hovered || this.isTrials){
this.drawCenteredString(minecraft.fontRenderer, StringUtil.localize("booklet."+ActuallyAdditions.MODID+".trialsButton.name"), this.x+(this.width-8)/2, this.y+(this.height-8)/2, 14737632);
if (this.visible) {
if (this.hovered || this.isTrials) {
this.drawCenteredString(minecraft.fontRenderer, StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trialsButton.name"), this.x + (this.width - 8) / 2, this.y + (this.height - 8) / 2, 14737632);
}
}
}
@Override
protected int getHoverState(boolean mouseOver){
if(mouseOver || this.isTrials){
protected int getHoverState(boolean mouseOver) {
if (mouseOver || this.isTrials) {
return 2;
}
else if(!this.enabled){
} else if (!this.enabled) {
return 0;
}
else{
} else {
return 1;
}
}

View file

@ -21,7 +21,7 @@ import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BookletChapter implements IBookletChapter{
public class BookletChapter implements IBookletChapter {
public final IBookletPage[] pages;
public final IBookletEntry entry;
@ -30,78 +30,76 @@ public class BookletChapter implements IBookletChapter{
private final int priority;
public TextFormatting color;
public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages){
public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) {
this(identifier, entry, displayStack, 0, pages);
}
public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, int priority, IBookletPage... pages){
public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, int priority, IBookletPage... pages) {
this.pages = pages;
this.identifier = identifier;
this.entry = entry;
this.displayStack = displayStack;
if(displayStack.getItem() instanceof IDisableableItem && ((IDisableableItem) displayStack.getItem()).isDisabled()) displayStack = ItemStack.EMPTY;
if (displayStack.getItem() instanceof IDisableableItem && ((IDisableableItem) displayStack.getItem()).isDisabled()) displayStack = ItemStack.EMPTY;
this.priority = priority;
this.color = TextFormatting.RESET;
this.entry.addChapter(this);
for(IBookletPage page : this.pages){
for (IBookletPage page : this.pages) {
page.setChapter(this);
}
}
@Override
public IBookletPage[] getAllPages(){
public IBookletPage[] getAllPages() {
return this.pages;
}
@Override
@SideOnly(Side.CLIENT)
public String getLocalizedName(){
return StringUtil.localize("booklet."+ActuallyAdditions.MODID+".chapter."+this.getIdentifier()+".name");
public String getLocalizedName() {
return StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".chapter." + this.getIdentifier() + ".name");
}
@Override
@SideOnly(Side.CLIENT)
public String getLocalizedNameWithFormatting(){
return this.color+this.getLocalizedName();
public String getLocalizedNameWithFormatting() {
return this.color + this.getLocalizedName();
}
@Override
public IBookletEntry getEntry(){
public IBookletEntry getEntry() {
return this.entry;
}
@Override
public ItemStack getDisplayItemStack(){
public ItemStack getDisplayItemStack() {
return this.displayStack;
}
@Override
public String getIdentifier(){
public String getIdentifier() {
return this.identifier;
}
@Override
public int getPageIndex(IBookletPage page){
for(int i = 0; i < this.pages.length; i++){
if(this.pages[i] == page){
return i;
}
public int getPageIndex(IBookletPage page) {
for (int i = 0; i < this.pages.length; i++) {
if (this.pages[i] == page) { return i; }
}
return -1;
}
@Override
public int getSortingPriority(){
public int getSortingPriority() {
return this.priority;
}
public BookletChapter setImportant(){
public BookletChapter setImportant() {
this.color = TextFormatting.DARK_GREEN;
return this;
}
public BookletChapter setSpecial(){
public BookletChapter setSpecial() {
this.color = TextFormatting.DARK_PURPLE;
return this;
}

View file

@ -10,6 +10,10 @@
package de.ellpeck.actuallyadditions.mod.booklet.chapter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
@ -19,23 +23,19 @@ import de.ellpeck.actuallyadditions.mod.booklet.page.PageCoffeeMachine;
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class BookletChapterCoffee extends BookletChapter {
public class BookletChapterCoffee extends BookletChapter{
public BookletChapterCoffee(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages){
public BookletChapterCoffee(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) {
super(identifier, entry, displayStack, getPages(pages));
}
private static IBookletPage[] getPages(IBookletPage... pages){
private static IBookletPage[] getPages(IBookletPage... pages) {
List<IBookletPage> allPages = new ArrayList<>();
allPages.addAll(Arrays.asList(pages));
for(CoffeeIngredient ingredient : ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS){
BookletPage page = new PageCoffeeMachine(allPages.size()+1, ingredient);
if(!(ingredient instanceof ItemCoffee.MilkIngredient)){
for (CoffeeIngredient ingredient : ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS) {
BookletPage page = new PageCoffeeMachine(allPages.size() + 1, ingredient);
if (!(ingredient instanceof ItemCoffee.MilkIngredient)) {
page.setNoText();
}
allPages.add(page);

Some files were not shown because too many files have changed in this diff Show more