This commit is contained in:
Glenthor 2016-07-04 22:29:22 +02:00
commit 980dc18085
1092 changed files with 18306 additions and 17631 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
/rebuild.bat
/doAllTheThings.bat
/.gradle
/build

View file

@ -4,27 +4,27 @@ The things listed below are special cases and exceptions from the above. They ha
Everything that is not listed below applies to the above.
### YOU MAY
* Fork and modify the Code
* Submit Pull Requests
* Copy (SMALL!) Parts of the Code for other Projects
* Make a Review/Spotlight of the Mod or use it in a Modpack
* Make Let's Play (and similar) Videos containing the Mod
* Fork and modify the code.
* Submit pull requests.
* Copy small parts of code for other projects.
* Make a review/spotlight of the mod or use it in a modpack.
* Make Let's Play (and similar) videos containing the mod.
### YOU CAN NOT
* Copy the entire Code or claim it is yours.
* Reupload the Code or Mod to another website or claim you made it.
* Copy entire Classes, Methods or other big Parts of Code.
* Copy entire classes, methods or features or claim you made them.
* Redistribute the mod. This does not apply, however, when it comes to pre-packaged modpacks.
### YOU HAVE TO
* Always credit me. Don't be a jerk and copy entire portions of the code and claim they're yours.
* When it comes to the code, always link back to this Repository.
* When it comes to the Mod, always link back to the the Forum Thread linked above.
* When modifying or using code, always explicitly credit Ellpeck as the creator.
* When making a review/spotlight containing the mod or using it in a modpack, always make clear that Actually Additions is used.
* When it comes to the code, always link back to the official repository.
* When it comes to the mod, always link back to the the official Minecraft Forum thread or CurseForge page.
### NOTES
* The Actually Additions API can be excerpted for use in other projects, however it should not be modified. It can be redistributed with other mods (if it is getting used), however it should still be visible that it is a part of Actually Additions. Do not remove the copyright header from any of the API's files.
* The above License only applies for Code I wrote myself, any APIs used (such as the CoFH API) have their own License that is being respected.
* There are some excerpts from other code used (such as the OpenBlocks XP System). Credit to the creators of these parts is always given and their Permission is granted or their License is respected.
* Almost all of the Assets used in this Mod are made by Glenthor and are owned by me. You are not allowed to copy them for any other Project.
* Parts of this License, especially restrictive ones, can be ignored with Personal Permission. Said Permission, however, will only be given to people I know or someone who has a very good reason for needing it. If you don't, don't ask.
* The above License only applies for code I wrote myself, any APIs used (such as the CoFH API) have their own License that is being respected.
* There are some excerpts from other code used (such as the OpenBlocks XP system). Credit to the creators of these parts is always given and their permission is granted or their license is respected.
* Almost all of the assets used in this mod are made by Glenthor and are owned by me. You are not allowed to copy them for any other project.
* Parts of this license, especially restrictive ones, can be ignored with personal permission. Said permission, however, will only be given to people I know or someone who has a very good reason for needing it.
© 2015-2016 Ellpeck

View file

@ -1,5 +1,5 @@
![](https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/pics/logoBig.png)
![](https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/pics/logo.png)
##It's a Minecraft Mod!
For more information, visit the main Minecraft Forum Thread at http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2551118
For more information, visit the main Minecraft Forum Thread by [clicking here](http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2551118)!

View file

@ -7,22 +7,24 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
version = "1.8.9-r25"
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'idea'
version = "1.10.2-r47"
group = "de.ellpeck.actuallyadditions"
archivesBaseName = "ActuallyAdditions"
minecraft {
version = "1.8.9-11.15.1.1732"
version = "1.10.2-12.18.0.2002-1.10.0"
runDir = "idea"
mappings = "stable_20"
mappings = "snapshot_20160519"
makeObfSourceJar = false
useDepAts = true
//useDepAts = true
replaceIn "ModUtil.java"
replace "@VERSION@", project.version.toString()
@ -35,6 +37,9 @@ repositories {
maven {
url "http://dvs1.progwml6.com/files/maven"
}
maven {
url "http://maven.epoxide.xyz"
}
}
dependencies {
@ -42,7 +47,8 @@ dependencies {
//compile "codechicken:CodeChickenCore:1.8-1.0.5.36:dev"
//compile "codechicken:NotEnoughItems:1.8-1.0.5.104:dev"
deobfCompile "mezz.jei:jei_1.8.9:2.25.6.140"
compile "net.darkhax.tesla:Tesla:1.9.4-1.1.0.24"
deobfCompile "mezz.jei:jei_1.10:3.7.1.219"
}
processResources {
@ -60,10 +66,13 @@ processResources {
}
}
jar {}
jar {
}
task deobfJar(type: Jar) {
from sourceSets.main.output
from sourceSets.main.java
classifier = 'dev'
}

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip

Binary file not shown.

Before

Width:  |  Height:  |  Size: 728 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 905 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 500 KiB

BIN
pics/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View file

@ -1,12 +1,15 @@
#Because he's me
ellpeck=ActuallyAdditions:itemBooklet@0
ellpeck=actuallyadditions:itemBooklet@0
#Because he submitted tons of ideas for the mod
dqmhose=minecraft:torch@0
#Because he does all of the textures
twoofeight=ActuallyAdditions:blockHeatCollector@0
twoofeight=actuallyadditions:blockHeatCollector@0
#Because she is awesome and squids are cool
larixine=ActuallyAdditions:blockBlackLotus@0
larixine=actuallyadditions:blockBlackLotus@0
#Because he helps me with models and stuff
canitzp=ActuallyAdditions:blockCoffeeMachine@0
canitzp=actuallyadditions:blockCoffeeMachine@0
#Because he's an awesome guy and helps with lots of stuff
xdjackiexd=ActuallyAdditions:itemDrill@14
xdjackiexd=actuallyadditions:itemDrill@14
#Patreon stuff
ftog_thorgal=actuallyadditions:itemCrystal@0

View file

@ -6,6 +6,6 @@ public class CoFHAPIProps {
}
public static final String VERSION = "1.7.10R1.0.2";
public static final String VERSION = "1.8.9R1.2.0B1";
}

View file

@ -51,29 +51,33 @@ public class EnergyStorage implements IEnergyStorage {
return nbt;
}
public void setCapacity(int capacity) {
public EnergyStorage setCapacity(int capacity) {
this.capacity = capacity;
if (energy > capacity) {
energy = capacity;
}
return this;
}
public void setMaxTransfer(int maxTransfer) {
public EnergyStorage setMaxTransfer(int maxTransfer) {
setMaxReceive(maxTransfer);
setMaxExtract(maxTransfer);
return this;
}
public void setMaxReceive(int maxReceive) {
public EnergyStorage setMaxReceive(int maxReceive) {
this.maxReceive = maxReceive;
return this;
}
public void setMaxExtract(int maxExtract) {
public EnergyStorage setMaxExtract(int maxExtract) {
this.maxExtract = maxExtract;
return this;
}
public int getMaxReceive() {
@ -87,7 +91,7 @@ public class EnergyStorage implements IEnergyStorage {
}
/**
* This function is included to allow for server -> client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers
* This function is included to allow for server to client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers
* are guaranteed to have it.
*
* @param energy

View file

@ -2,6 +2,7 @@ package cofh.api.energy;
import net.minecraft.util.EnumFacing;
/**
* Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not
* accept it; otherwise just use IEnergyHandler.

View file

@ -6,53 +6,22 @@ import net.minecraft.util.EnumFacing;
* Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
* <p>
* A reference implementation is provided {@link TileEnergyHandler}.
* <p>
* Note that {@link IEnergyReceiver} and {@link IEnergyProvider} are extensions of this.
*
* @author King Lemming
*
*/
public interface IEnergyHandler extends IEnergyProvider, IEnergyReceiver {
// merely a convenience interface (remove these methods in 1.8; provided here for back-compat via compiler doing things)
/**
* Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver.
*
* @param from
* Orientation the energy is received from.
* @param maxReceive
* Maximum amount of energy to receive.
* @param simulate
* If TRUE, the charge will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) received.
*/
@Override
int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate);
/**
* Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider.
*
* @param from
* Orientation the energy is extracted from.
* @param maxExtract
* Maximum amount of energy to extract.
* @param simulate
* If TRUE, the extraction will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) extracted.
*/
@Override
int extractEnergy(EnumFacing from, int maxExtract, boolean simulate);
public interface IEnergyHandler extends IEnergyConnection {
/**
* Returns the amount of energy currently stored.
*/
@Override
int getEnergyStored(EnumFacing from);
/**
* Returns the maximum amount of energy that can be stored.
*/
@Override
int getMaxEnergyStored(EnumFacing from);
}

View file

@ -2,6 +2,7 @@ package cofh.api.energy;
import net.minecraft.util.EnumFacing;
/**
* Implement this interface on Tile Entities which should provide energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
* <p>
@ -10,7 +11,7 @@ import net.minecraft.util.EnumFacing;
* @author King Lemming
*
*/
public interface IEnergyProvider extends IEnergyConnection {
public interface IEnergyProvider extends IEnergyHandler {
/**
* Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider.
@ -25,14 +26,4 @@ public interface IEnergyProvider extends IEnergyConnection {
*/
int extractEnergy(EnumFacing from, int maxExtract, boolean simulate);
/**
* Returns the amount of energy currently stored.
*/
int getEnergyStored(EnumFacing from);
/**
* Returns the maximum amount of energy that can be stored.
*/
int getMaxEnergyStored(EnumFacing from);
}

View file

@ -2,6 +2,7 @@ package cofh.api.energy;
import net.minecraft.util.EnumFacing;
/**
* Implement this interface on Tile Entities which should receive energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
* <p>
@ -10,7 +11,7 @@ import net.minecraft.util.EnumFacing;
* @author King Lemming
*
*/
public interface IEnergyReceiver extends IEnergyConnection {
public interface IEnergyReceiver extends IEnergyHandler {
/**
* Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver.
@ -25,14 +26,4 @@ public interface IEnergyReceiver extends IEnergyConnection {
*/
int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate);
/**
* Returns the amount of energy currently stored.
*/
int getEnergyStored(EnumFacing from);
/**
* Returns the maximum amount of energy that can be stored.
*/
int getMaxEnergyStored(EnumFacing from);
}

View file

@ -43,27 +43,30 @@ public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
return this;
}
public void setMaxTransfer(int maxTransfer) {
public ItemEnergyContainer setMaxTransfer(int maxTransfer) {
setMaxReceive(maxTransfer);
setMaxExtract(maxTransfer);
return this;
}
public void setMaxReceive(int maxReceive) {
public ItemEnergyContainer setMaxReceive(int maxReceive) {
this.maxReceive = maxReceive;
return this;
}
public void setMaxExtract(int maxExtract) {
public ItemEnergyContainer setMaxExtract(int maxExtract) {
this.maxExtract = maxExtract;
return this;
}
/* IEnergyContainerItem */
@Override
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
if (container.getTagCompound() == null) {
if (!container.hasTagCompound()) {
container.setTagCompound(new NBTTagCompound());
}
int energy = container.getTagCompound().getInteger("Energy");

View file

@ -1,65 +0,0 @@
package cofh.api.energy;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
/**
* Reference implementation of {@link IEnergyHandler}. Use/extend this or implement your own.
*
* @author King Lemming
*
*/
public class TileEnergyHandler extends TileEntity implements IEnergyHandler {
protected EnergyStorage storage = new EnergyStorage(32000);
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
storage.readFromNBT(nbt);
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
storage.writeToNBT(nbt);
}
/* IEnergyConnection */
@Override
public boolean canConnectEnergy(EnumFacing from) {
return true;
}
/* IEnergyReceiver */
@Override
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) {
return storage.receiveEnergy(maxReceive, simulate);
}
/* IEnergyProvider */
@Override
public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) {
return storage.extractEnergy(maxExtract, simulate);
}
/* IEnergyReceiver and IEnergyProvider */
@Override
public int getEnergyStored(EnumFacing from) {
return storage.getEnergyStored();
}
@Override
public int getMaxEnergyStored(EnumFacing from) {
return storage.getMaxEnergyStored();
}
}

View file

@ -1,10 +1,10 @@
/**
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
* (C) 2014-2016 Team CoFH / CoFH / Cult of the Full Hub
* http://www.teamcofh.com
*/
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|energy")
package cofh.api.energy;
import cofh.api.CoFHAPIProps;
import net.minecraftforge.fml.common.API;
import cofh.api.CoFHAPIProps;

View file

@ -1,8 +1,9 @@
/**
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
* (C) 2014-2016 Team CoFH / CoFH / Cult of the Full Hub
* http://www.teamcofh.com
*/
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHLib", provides = "CoFHAPI")
package cofh.api;
import net.minecraftforge.fml.common.API;
import net.minecraftforge.fml.common.API;

View file

@ -1,44 +1,53 @@
/*
* This file ("ActuallyAdditionsAPI.java") is part of the Actually Additions Mod for Minecraft.
* This file ("ActuallyAdditionsAPI.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api;
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.recipe.BallOfFurReturn;
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
import de.ellpeck.actuallyadditions.api.recipe.LensNoneRecipe;
import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot;
import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeIngredient;
import de.ellpeck.actuallyadditions.api.internal.IMethodHandler;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
import de.ellpeck.actuallyadditions.api.recipe.*;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public 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_VERSION = "8";
public static List<CrusherRecipe> crusherRecipes = new ArrayList<CrusherRecipe>();
public static List<BallOfFurReturn> ballOfFurReturnItems = new ArrayList<BallOfFurReturn>();
public static List<TreasureChestLoot> treasureChestLoot = new ArrayList<TreasureChestLoot>();
public static List<LensNoneRecipe> reconstructorLensNoneRecipes = new ArrayList<LensNoneRecipe>();
public static List<CoffeeIngredient> coffeeMachineIngredients = new ArrayList<CoffeeIngredient>();
public static List<IBookletEntry> bookletEntries = new ArrayList<IBookletEntry>();
public static List<BookletPage> bookletPagesWithItemStackData = new ArrayList<BookletPage>();
//These are getting initlized in Actually Additions' PreInit phase
public static final String MOD_ID = "actuallyadditions";
public static final String API_ID = MOD_ID+"api";
public static final String API_VERSION = "17";
public static final List<CrusherRecipe> CRUSHER_RECIPES = new ArrayList<CrusherRecipe>();
public static final List<BallOfFurReturn> BALL_OF_FUR_RETURN_ITEMS = new ArrayList<BallOfFurReturn>();
public static final List<TreasureChestLoot> TREASURE_CHEST_LOOT = new ArrayList<TreasureChestLoot>();
public static final List<LensConversionRecipe> RECONSTRUCTOR_LENS_CONVERSION_RECIPES = new ArrayList<LensConversionRecipe>();
public static final Map<Item, IColorLensChanger> RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap<Item, IColorLensChanger>();
public static final List<CoffeeIngredient> COFFEE_MACHINE_INGREDIENTS = new ArrayList<CoffeeIngredient>();
public static final List<CompostRecipe> COMPOST_RECIPES = new ArrayList<CompostRecipe>();
public static final List<IBookletEntry> BOOKLET_ENTRIES = new ArrayList<IBookletEntry>();
public static final List<BookletPage> BOOKLET_PAGES_WITH_ITEM_DATA = new ArrayList<BookletPage>();
/**
* Use this to handle things that aren't based in the API itself
* DO NOT CHANGE/OVERRIDE THIS!!
* This is getting initialized in Actually Additions' PreInit phase
*/
public static IMethodHandler methodHandler;
//These are getting initialized in Actually Additions' PreInit phase
//DO NOT CHANGE/OVERRIDE THESE!!
public static IBookletEntry entryGettingStarted;
public static IBookletEntry entryFunctionalNonRF;
public static IBookletEntry entryFunctionalRF;
@ -48,6 +57,14 @@ public class ActuallyAdditionsAPI{
public static IBookletEntry entryMisc;
public static IBookletEntry allAndSearch;
//These are getting initialized in Actually Additions' PreInit phase
//DO NOT CHANGE/OVERRIDE THESE!!
public static LensConversion lensDefaultConversion;
public static Lens lensDetonation;
public static Lens lensDeath;
public static Lens lensColor;
public static Lens lensDisruption;
/**
* Adds a Recipe to the Crusher Recipe Registry
* The second output will be nothing
@ -71,8 +88,8 @@ public class ActuallyAdditionsAPI{
* @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time)
*/
public static void addCrusherRecipe(String input, String outputOne, int outputOneAmount, String outputTwo, int outputTwoAmount, int outputTwoChance){
if(!OreDictionary.getOres(input).isEmpty() && !OreDictionary.getOres(outputOne).isEmpty() && (outputTwo == null || outputTwo.isEmpty() || !OreDictionary.getOres(outputTwo).isEmpty())){
crusherRecipes.add(new CrusherRecipe(input, outputOne, outputOneAmount, outputTwo, outputTwoAmount, outputTwoChance));
if(!OreDictionary.getOres(input, false).isEmpty() && !OreDictionary.getOres(outputOne, false).isEmpty() && (outputTwo == null || outputTwo.isEmpty() || !OreDictionary.getOres(outputTwo, false).isEmpty())){
CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne, outputOneAmount, outputTwo, outputTwoAmount, outputTwoChance));
}
}
@ -97,7 +114,7 @@ public class ActuallyAdditionsAPI{
* @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){
crusherRecipes.add(new CrusherRecipe(input, outputOne, outputTwo, outputTwoChance));
CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne, outputTwo, outputTwoChance));
}
/**
@ -109,11 +126,24 @@ public class ActuallyAdditionsAPI{
* @param outputOneAmount The amount of the first output
*/
public static void addCrusherRecipe(ItemStack input, String outputOne, int outputOneAmount){
if(!OreDictionary.getOres(outputOne).isEmpty()){
crusherRecipes.add(new CrusherRecipe(input, outputOne, outputOneAmount));
if(!OreDictionary.getOres(outputOne, false).isEmpty()){
CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne, outputOneAmount));
}
}
/**
* Adds a new conversion recipe to the compost.
* StackSize is regarded on both input and output and they can be different.
*
* @param input The itemstack to be input into the compost
* @param inputDisplay The block to display when there is input in the compost
* @param output The itemstack to be output from the compost once conversion finishes
* @param outputDisplay The block to display when there is output in the compost
*/
public static void addCompostRecipe(ItemStack input, Block inputDisplay, ItemStack output, Block outputDisplay){
COMPOST_RECIPES.add(new CompostRecipe(input, inputDisplay, output, outputDisplay));
}
/**
* Adds an item to the list of possible items to be returned when right-clicking a Ball Of Fur
*
@ -121,7 +151,7 @@ public class ActuallyAdditionsAPI{
* @param chance The chance (this is from WeightedRandom.Item)
*/
public static void addBallOfFurReturnItem(ItemStack stack, int chance){
ActuallyAdditionsAPI.ballOfFurReturnItems.add(new BallOfFurReturn(stack, chance));
BALL_OF_FUR_RETURN_ITEMS.add(new BallOfFurReturn(stack, chance));
}
/**
@ -133,30 +163,55 @@ public class ActuallyAdditionsAPI{
* @param maxAmount The maximum stacksize of the returned stack
*/
public static void addTreasureChestLoot(ItemStack stack, int chance, int minAmount, int maxAmount){
ActuallyAdditionsAPI.treasureChestLoot.add(new TreasureChestLoot(stack, chance, minAmount, maxAmount));
TREASURE_CHEST_LOOT.add(new TreasureChestLoot(stack, chance, minAmount, maxAmount));
}
/**
* Adds a recipe to the Atomic Reconstructor conversion without lens
* Adds a recipe to the Atomic Reconstructor conversion lenses
* StackSizes can only be 1 and greater ones will be ignored
*
* @param input The input as an ItemStack
* @param output The output as an ItemStack
* @param energyUse The amount of RF used per conversion
* @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 addReconstructorLensNoneRecipe(ItemStack input, ItemStack output, int energyUse){
reconstructorLensNoneRecipes.add(new LensNoneRecipe(input, output, energyUse));
public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse, LensConversion type){
RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type));
}
public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse){
addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
}
/**
* Adds a recipe to the Atomic Reconstructor conversion without lens
* Adds a recipe to the Atomic Reconstructor conversion lenses
*
* @param input The input's OreDictionary name
* @param output The output's OreDictionary name
* @param energyUse The amount of RF used per conversion
* @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 addReconstructorLensNoneRecipe(String input, String output, int energyUse){
reconstructorLensNoneRecipes.add(new LensNoneRecipe(input, output, energyUse));
public static void addReconstructorLensConversionRecipe(String input, String output, int energyUse, LensConversion type){
RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type));
}
public static void addReconstructorLensConversionRecipe(String input, String output, int energyUse){
addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
}
/**
* Adds an item and the way it is modified to the Atomic Reconstructor's color lens.
* This also works for blocks, but they have to be in their item form.
* The way it is modified is an instance of IColorLensChanger. When modifying the item,
* its modifyItem() method will be called with a stack containing the item.
*
* @param item The item (or block's item) to add
* @param changer The change mechanism
*/
public static void addReconstructorLensColorChangeItem(Item item, IColorLensChanger changer){
RECONSTRUCTOR_LENS_COLOR_CHANGERS.put(item, changer);
}
/**
@ -165,7 +220,7 @@ public class ActuallyAdditionsAPI{
* @param ingredient The ingredient to add
*/
public static void addCoffeeMachineIngredient(CoffeeIngredient ingredient){
coffeeMachineIngredients.add(ingredient);
COFFEE_MACHINE_INGREDIENTS.add(ingredient);
}
/**
@ -174,7 +229,7 @@ public class ActuallyAdditionsAPI{
* @param entry The entry to add
*/
public static void addBookletEntry(IBookletEntry entry){
bookletEntries.add(entry);
BOOKLET_ENTRIES.add(entry);
}
/**
@ -184,6 +239,6 @@ public class ActuallyAdditionsAPI{
* @param page The page to add
*/
public static void addPageWithItemStackData(BookletPage page){
bookletPagesWithItemStackData.add(page);
BOOKLET_PAGES_WITH_ITEM_DATA.add(page);
}
}

View file

@ -1,16 +1,17 @@
/*
* This file ("IBookletPage.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BookletPage.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.booklet;
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -20,6 +21,18 @@ public abstract class BookletPage{
public boolean arePageStacksWildcard;
protected IBookletChapter chapter;
public void onOpened(IBookletGui gui){
}
public void onClosed(IBookletGui gui){
}
public boolean onActionPerformed(IBookletGui gui, GuiButton button){
return false;
}
/**
* The ID of the page, for the page number etc.
* Don't make two pages in the same chapter with the same ID.

View file

@ -1,11 +1,11 @@
/*
* This file ("IBookletChapter.java") is part of the Actually Additions Mod for Minecraft.
* This file ("IBookletChapter.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.booklet;

View file

@ -1,11 +1,11 @@
/*
* This file ("IBookletEntry.java") is part of the Actually Additions Mod for Minecraft.
* This file ("IBookletEntry.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.booklet;

View file

@ -1,15 +1,16 @@
/*
* This file ("IAtomicReconstructor.java") is part of the Actually Additions Mod for Minecraft.
* This file ("IAtomicReconstructor.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.internal;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import net.minecraft.world.World;
/**
@ -49,4 +50,6 @@ public interface IAtomicReconstructor{
* Gets the amount of energy the Reconstructor has stored in its RF storage
*/
int getEnergy();
Lens getLens();
}

View file

@ -1,20 +1,23 @@
/*
* This file ("IBookletGui.java") is part of the Actually Additions Mod for Minecraft.
* This file ("IBookletGui.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.internal;
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
/**
* This is a helper interface for BookletPage
* This is not supposed to be implemented.
@ -27,9 +30,8 @@ public interface IBookletGui{
* This method should be used when drawing an ItemStack to a booklet page
* It displays the hoverover text of the item and also contains the "show more info"-text and clickable part
*
* @param renderTransferButton if the "show more info"-text and clickable part should exist-
* @param renderTransferButton if the "show more info"-text and clickable part should exist
*/
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
void renderTooltipAndTransferButton(BookletPage from, ItemStack stack, int x, int y, boolean renderTransferButton, boolean mousePressed);
@ -43,5 +45,7 @@ public interface IBookletGui{
void drawRect(int startX, int startY, int u, int v, int xSize, int ySize);
EntrySet getCurrentEntrySet();
IEntrySet getCurrentEntrySet();
List<GuiButton> getButtonList();
}

View file

@ -0,0 +1,41 @@
/*
* This file ("IEntrySet.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.internal;
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import net.minecraft.nbt.NBTTagCompound;
public interface IEntrySet{
void setEntry(BookletPage page, IBookletChapter chapter, IBookletEntry entry, int pageInIndex);
void removeEntry();
NBTTagCompound writeToNBT();
BookletPage getCurrentPage();
IBookletEntry getCurrentEntry();
IBookletChapter getCurrentChapter();
int getPageInIndex();
void setPage(BookletPage page);
void setEntry(IBookletEntry entry);
void setChapter(IBookletChapter chapter);
void setPageInIndex(int page);
}

View file

@ -0,0 +1,37 @@
/*
* This file ("IMethodHandler.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.internal;
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.math.BlockPos;
/**
* This is the internal method handler.
* Use ActuallyAdditionsAPI.methodHandler for calling
* This is not supposed to be implemented.
*/
public interface IMethodHandler{
boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient);
PotionEffect getSameEffectFromStack(ItemStack stack, PotionEffect effect);
void addEffectProperties(ItemStack stack, PotionEffect effect, boolean addDur, boolean addAmp);
void addEffectToStack(ItemStack stack, PotionEffect effect);
PotionEffect[] getEffectsFromStack(ItemStack stack);
boolean invokeConversionLens(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile);
}

View file

@ -1,11 +1,11 @@
/*
* This file ("ILensItem.java") is part of the Actually Additions Mod for Minecraft.
* This file ("ILensItem.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.lens;

View file

@ -1,22 +1,22 @@
/*
* This file ("Lens.java") is part of the Actually Additions Mod for Minecraft.
* This file ("Lens.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.lens;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraft.util.math.BlockPos;
/**
* This is the base class for a Reconstructor Lens Type (NOT THE ITEM!)
* You need to call register() to register the type
*/
public abstract class Lens{
@ -32,7 +32,7 @@ public abstract class Lens{
* @param tile The tile the lens was invoked from
* @return If the Reconstructor should stop continuing (return false if you want it to go through blocks)
*/
public abstract boolean invoke(BlockPos hitBlock, IAtomicReconstructor tile);
public abstract boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile);
/**
* Returns the color in an array of 3 float values that are r, g, b
@ -40,12 +40,12 @@ public abstract class Lens{
public abstract float[] getColor();
/**
* Gets the maximum distance the beam goes with this lense
* Gets the maximum distance the beam goes with this lens
*/
public abstract int getDistance();
/**
* Sets the item corresponding to the lense
* Sets the item corresponding to the lens
*/
public void setLensItem(Item item){
this.lensItem = item;

View file

@ -0,0 +1,43 @@
/*
* This file ("LensConversion.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
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;
import net.minecraft.util.math.BlockPos;
/**
* This is the base class for a Reconstructor Lens Type that converts two items
* via the ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES list.
* <p>
* 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{
@Override
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};
}
@Override
public int getDistance(){
return 10;
}
}

View file

@ -0,0 +1,21 @@
/*
* This file ("IDisplayStandItem.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.misc;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
public interface IDisplayStandItem{
boolean update(ItemStack stack, TileEntity tile, int elapsedTicks);
int getUsePerTick(ItemStack stack, TileEntity tile, int elapsedTicks);
}

View file

@ -1,11 +1,11 @@
/*
* This file ("package-info.java") is part of the Actually Additions Mod for Minecraft.
* This file ("package-info.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
@API(owner = ActuallyAdditionsAPI.MOD_ID, apiVersion = ActuallyAdditionsAPI.API_VERSION, provides = ActuallyAdditionsAPI.API_ID)
package de.ellpeck.actuallyadditions.api;

View file

@ -1,11 +1,11 @@
/*
* This file ("BallOfFurReturn.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BallOfFurReturn.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.recipe;
@ -15,7 +15,7 @@ import net.minecraft.util.WeightedRandom;
public class BallOfFurReturn extends WeightedRandom.Item{
public ItemStack returnItem;
public final ItemStack returnItem;
public BallOfFurReturn(ItemStack returnItem, int chance){
super(chance);

View file

@ -1,15 +1,16 @@
/*
* This file ("CoffeeIngredient.java") is part of the Actually Additions Mod for Minecraft.
* This file ("CoffeeIngredient.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.recipe.coffee;
package de.ellpeck.actuallyadditions.api.recipe;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
@ -30,7 +31,7 @@ public class CoffeeIngredient{
}
public boolean effect(ItemStack stack){
return CoffeeBrewing.addEffectToStack(stack, this);
return ActuallyAdditionsAPI.methodHandler.addEffectToStack(stack, this);
}
public String getExtraText(){

View file

@ -0,0 +1,36 @@
/*
* This file ("ColorLensChangerByDyeMeta.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.recipe;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
/**
* Changes an item's color by changing its metadata.
* Much like dye and wool, 0 is white and 15 is black and it will cycle around.
*/
public class ColorLensChangerByDyeMeta implements IColorLensChanger{
@Override
public ItemStack modifyItem(ItemStack stack, IBlockState hitBlockState, BlockPos hitBlock, IAtomicReconstructor tile){
ItemStack newStack = stack.copy();
int meta = newStack.getItemDamage();
if(meta >= 15){
newStack.setItemDamage(0);
}
else{
newStack.setItemDamage(meta+1);
}
return newStack;
}
}

View file

@ -0,0 +1,30 @@
/*
* This file ("CompostRecipe.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.recipe;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
public class CompostRecipe{
public final ItemStack input;
public final ItemStack output;
public final Block inputDisplay;
public final Block outputDisplay;
public CompostRecipe(ItemStack input, Block inputDisplay, ItemStack output, Block outputDisplay){
this.input = input;
this.output = output;
this.inputDisplay = inputDisplay;
this.outputDisplay = outputDisplay;
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("CrusherRecipe.java") is part of the Actually Additions Mod for Minecraft.
* This file ("CrusherRecipe.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.recipe;
@ -60,7 +60,7 @@ public class CrusherRecipe{
return null;
}
List<ItemStack> stacks = OreDictionary.getOres(this.outputOne);
List<ItemStack> stacks = OreDictionary.getOres(this.outputOne, false);
if(stacks != null && !stacks.isEmpty()){
List<ItemStack> stacksCopy = new ArrayList<ItemStack>();
for(ItemStack stack : stacks){
@ -84,7 +84,7 @@ public class CrusherRecipe{
return null;
}
List<ItemStack> stacks = OreDictionary.getOres(this.outputTwo);
List<ItemStack> stacks = OreDictionary.getOres(this.outputTwo, false);
if(stacks != null && !stacks.isEmpty()){
List<ItemStack> stacksCopy = new ArrayList<ItemStack>();
for(ItemStack stack : stacks){
@ -108,7 +108,7 @@ public class CrusherRecipe{
return null;
}
List<ItemStack> stacks = OreDictionary.getOres(this.input);
List<ItemStack> stacks = OreDictionary.getOres(this.input, false);
if(stacks != null && !stacks.isEmpty()){
List<ItemStack> stacksCopy = new ArrayList<ItemStack>();
for(ItemStack stack : stacks){

View file

@ -0,0 +1,40 @@
/*
* This file ("IColorLensChanger.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.recipe;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
/**
* Used for the Atomic Reconstructor's Color Lens changing algorythm.
* When registering a new item to be changed, it needs an IColorLensChanger which
* is the method with which the item will be changed.
* <p>
* See ColorLensChangerByDyeMeta for reference.
*/
public interface IColorLensChanger{
/**
* Modifies the given item.
* Will only be called with stacks containing items that are registered with
* this IColorLensChanger.
*
* @param stack the stack to modify
* @param hitBlockState The state of the block that was hit
* @param hitBlock the block that was hit (usually air, or the block that is also in the stack)
* @param tile the Reconstructor doing the color conversion
* @return the modified stack. Please make sure to return a modified COPY of the input stack.
*/
ItemStack modifyItem(ItemStack stack, IBlockState hitBlockState, BlockPos hitBlock, IAtomicReconstructor tile);
}

View file

@ -1,15 +1,16 @@
/*
* This file ("LensNoneRecipe.java") is part of the Actually Additions Mod for Minecraft.
* This file ("LensConversionRecipe.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.recipe;
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
@ -17,24 +18,27 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class LensNoneRecipe{
public class LensConversionRecipe{
public int energyUse;
public final int energyUse;
public final LensConversion type;
private String input;
private String output;
private ItemStack inputStack;
private ItemStack outputStack;
public LensNoneRecipe(ItemStack input, ItemStack output, int energyUse){
public LensConversionRecipe(ItemStack input, ItemStack output, int energyUse, LensConversion type){
this.inputStack = input;
this.outputStack = output;
this.energyUse = energyUse;
this.type = type;
}
public LensNoneRecipe(String input, String output, int energyUse){
public LensConversionRecipe(String input, String output, int energyUse, LensConversion type){
this.input = input;
this.output = output;
this.energyUse = energyUse;
this.type = type;
}
public List<ItemStack> getOutputs(){
@ -46,7 +50,7 @@ public class LensNoneRecipe{
return null;
}
List<ItemStack> stacks = OreDictionary.getOres(this.output);
List<ItemStack> stacks = OreDictionary.getOres(this.output, false);
if(stacks != null && !stacks.isEmpty()){
List<ItemStack> stacksCopy = new ArrayList<ItemStack>();
for(ItemStack stack : stacks){
@ -70,7 +74,7 @@ public class LensNoneRecipe{
return null;
}
List<ItemStack> stacks = OreDictionary.getOres(this.input);
List<ItemStack> stacks = OreDictionary.getOres(this.input, false);
if(stacks != null && !stacks.isEmpty()){
List<ItemStack> stacksCopy = new ArrayList<ItemStack>();
for(ItemStack stack : stacks){

View file

@ -1,11 +1,11 @@
/*
* This file ("TreasureChestLoot.java") is part of the Actually Additions Mod for Minecraft.
* This file ("TreasureChestLoot.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.recipe;
@ -15,9 +15,9 @@ import net.minecraft.util.WeightedRandom;
public class TreasureChestLoot extends WeightedRandom.Item{
public ItemStack returnItem;
public int minAmount;
public int maxAmount;
public final ItemStack returnItem;
public final int minAmount;
public final int maxAmount;
public TreasureChestLoot(ItemStack returnItem, int chance, int minAmount, int maxAmount){
super(chance);

View file

@ -1,107 +0,0 @@
/*
* This file ("CoffeeBrewing.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.recipe.coffee;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import java.util.ArrayList;
/**
* This is a util class for adding Ingredients to ItemStacks
* Use when making a custom Coffee Ingredient
*/
public class CoffeeBrewing{
public static boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient){
boolean worked = false;
if(ingredient != null){
PotionEffect[] effects = ingredient.getEffects();
if(effects != null && effects.length > 0){
for(PotionEffect effect : effects){
PotionEffect effectHas = getSameEffectFromStack(stack, effect);
if(effectHas != null){
if(effectHas.getAmplifier() < ingredient.maxAmplifier-1){
addEffectProperties(stack, effect, false, true);
worked = true;
}
}
else{
addEffectToStack(stack, effect);
worked = true;
}
}
}
}
return worked;
}
public static PotionEffect getSameEffectFromStack(ItemStack stack, PotionEffect effect){
PotionEffect[] effectsStack = getEffectsFromStack(stack);
if(effectsStack != null && effectsStack.length > 0){
for(PotionEffect effectStack : effectsStack){
if(effect.getPotionID() == effectStack.getPotionID()){
return effectStack;
}
}
}
return null;
}
public static void addEffectProperties(ItemStack stack, PotionEffect effect, boolean addDur, boolean addAmp){
PotionEffect[] effects = getEffectsFromStack(stack);
stack.setTagCompound(new NBTTagCompound());
for(int i = 0; i < effects.length; i++){
if(effects[i].getPotionID() == effect.getPotionID()){
effects[i] = new PotionEffect(effects[i].getPotionID(), effects[i].getDuration()+(addDur ? effect.getDuration() : 0), effects[i].getAmplifier()+(addAmp ? (effect.getAmplifier() > 0 ? effect.getAmplifier() : 1) : 0));
}
addEffectToStack(stack, effects[i]);
}
}
public static void addEffectToStack(ItemStack stack, PotionEffect effect){
NBTTagCompound tag = stack.getTagCompound();
if(tag == null){
tag = new NBTTagCompound();
}
int prevCounter = tag.getInteger("Counter");
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("ID", effect.getPotionID());
compound.setInteger("Duration", effect.getDuration());
compound.setInteger("Amplifier", effect.getAmplifier());
int counter = prevCounter+1;
tag.setTag(counter+"", compound);
tag.setInteger("Counter", counter);
stack.setTagCompound(tag);
}
public static PotionEffect[] getEffectsFromStack(ItemStack stack){
ArrayList<PotionEffect> effects = new ArrayList<PotionEffect>();
NBTTagCompound tag = stack.getTagCompound();
if(tag != null){
int counter = tag.getInteger("Counter");
while(counter > 0){
NBTTagCompound compound = (NBTTagCompound)tag.getTag(counter+"");
PotionEffect effect = new PotionEffect(compound.getInteger("ID"), compound.getInteger("Duration"), compound.getByte("Amplifier"));
if(effect.getPotionID() > 0){
effects.add(effect);
}
counter--;
}
}
return effects.size() > 0 ? effects.toArray(new PotionEffect[effects.size()]) : null;
}
}

View file

@ -1,16 +1,16 @@
/*
* This file ("IPhantomTile.java") is part of the Actually Additions Mod for Minecraft.
* This file ("IPhantomTile.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.api.tile;
import net.minecraft.util.BlockPos;
import net.minecraft.util.math.BlockPos;
/**
* Extending this will cause a TileEntity to be able to be connected via a Phantom Connector

View file

@ -1,15 +1,16 @@
/*
* This file ("ActuallyAdditions.java") is part of the Actually Additions Mod for Minecraft.
* This file ("ActuallyAdditions.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.achievement.InitAchievements;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.booklet.InitBooklet;
@ -17,7 +18,7 @@ import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler;
import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting;
import de.ellpeck.actuallyadditions.mod.crafting.InitCrafting;
import de.ellpeck.actuallyadditions.mod.crafting.ItemCrafting;
import de.ellpeck.actuallyadditions.mod.event.InitEvents;
import de.ellpeck.actuallyadditions.mod.event.CommonEvents;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.gen.InitVillager;
import de.ellpeck.actuallyadditions.mod.gen.OreGen;
@ -25,10 +26,14 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.InitForeignPaxels;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
import de.ellpeck.actuallyadditions.mod.items.lens.LensNoneRecipeHandler;
import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler;
import de.ellpeck.actuallyadditions.mod.items.lens.Lenses;
import de.ellpeck.actuallyadditions.mod.material.InitArmorMaterials;
import de.ellpeck.actuallyadditions.mod.material.InitToolMaterials;
import de.ellpeck.actuallyadditions.mod.misc.*;
import de.ellpeck.actuallyadditions.mod.misc.BannerHelper;
import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot;
import de.ellpeck.actuallyadditions.mod.misc.MethodHandler;
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
import de.ellpeck.actuallyadditions.mod.ore.InitOreDict;
import de.ellpeck.actuallyadditions.mod.proxy.IProxy;
@ -37,16 +42,16 @@ import de.ellpeck.actuallyadditions.mod.recipe.HairyBallHandler;
import de.ellpeck.actuallyadditions.mod.recipe.TreasureChestHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
import de.ellpeck.actuallyadditions.mod.util.FakePlayerUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.init.Items;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.*;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import java.util.Locale;
@ -57,13 +62,22 @@ public class ActuallyAdditions{
@Instance(ModUtil.MOD_ID)
public static ActuallyAdditions instance;
@SidedProxy(clientSide = "de.ellpeck.actuallyadditions.mod.proxy.ClientProxy", serverSide = "de.ellpeck.actuallyadditions.mod.proxy.ServerProxy")
@SidedProxy(clientSide = ModUtil.PROXY_CLIENT, serverSide = ModUtil.PROXY_SERVER)
public static IProxy proxy;
static{
//For some reason, this has to be done here
FluidRegistry.enableUniversalBucket();
}
@EventHandler
public void preInit(FMLPreInitializationEvent event){
ModUtil.LOGGER.info("Starting PreInitialization Phase...");
ActuallyAdditionsAPI.methodHandler = new MethodHandler();
Lenses.init();
InitBooklet.preInit();
new ConfigurationHandler(event.getSuggestedConfigurationFile());
PacketHandler.init();
InitToolMaterials.init();
@ -72,8 +86,9 @@ public class ActuallyAdditions{
InitFluids.init();
InitItems.init();
FuelHandler.init();
UpdateChecker.init();
InitBooklet.preInit();
BannerHelper.init();
SoundHandler.init();
new UpdateChecker();
proxy.preInit(event);
ModUtil.LOGGER.info("PreInitialization Finished.");
@ -86,11 +101,12 @@ public class ActuallyAdditions{
InitOreDict.init();
InitAchievements.init();
GuiHandler.init();
OreGen.init();
new OreGen();
TileEntityBase.init();
InitEvents.init();
new CommonEvents();
InitCrafting.init();
DungeonLoot.init();
proxy.init(event);
ModUtil.LOGGER.info("Initialization Finished.");
@ -106,41 +122,25 @@ public class ActuallyAdditions{
ItemCrafting.initMashedFoodRecipes();
HairyBallHandler.init();
TreasureChestHandler.init();
LensNoneRecipeHandler.init();
LensRecipeHandler.init();
InitForeignPaxels.init();
InitBooklet.postInit();
proxy.postInit(event);
ModUtil.LOGGER.info("PostInitialization Finished.");
FakePlayerUtil.info();
}
@EventHandler
public void serverStarting(FMLServerStartingEvent event){
Util.registerDispenserHandler(InitItems.itemBucketOil, new DispenserHandlerEmptyBucket());
Util.registerDispenserHandler(InitItems.itemBucketCanolaOil, new DispenserHandlerEmptyBucket());
Util.registerDispenserHandler(Items.bucket, new DispenserHandlerFillBucket());
Util.registerDispenserHandler(InitItems.itemFertilizer, new DispenserHandlerFertilize());
}
@EventHandler
public void serverStarted(FMLServerStartedEvent event){
if(LaserRelayConnectionHandler.getInstance() == null){
LaserRelayConnectionHandler.setInstance(new LaserRelayConnectionHandler());
}
WorldData.init(MinecraftServer.getServer());
}
@EventHandler
public void missingMapping(FMLMissingMappingsEvent event){
for(FMLMissingMappingsEvent.MissingMapping mapping : event.getAll()){
//Ignore removal of foreign paxels
if(mapping.name != null && mapping.name.toLowerCase(Locale.ROOT).startsWith(ModUtil.MOD_ID_LOWER+":")){
if(mapping.name.contains("paxel") || mapping.name.contains("itemSpecial") || mapping.name.contains("blockBookStand")){
mapping.ignore();
ModUtil.LOGGER.info("Missing Mapping "+mapping.name+" is getting ignored. This is intentional.");
if(mapping.name != null){
String name = mapping.name.toLowerCase(Locale.ROOT);
if(name.startsWith(ModUtil.MOD_ID+":")){
if(name.contains("paxel") || name.contains("itemspecial") || name.contains("blockbookstand") || name.contains("rarmor") || name.contains("bucket") || name.contains("modulereconstructor")){
mapping.ignore();
ModUtil.LOGGER.info("Missing Mapping "+mapping.name+" is getting ignored. This is intentional.");
}
}
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("InitAchievements.java") is part of the Actually Additions Mod for Minecraft.
* This file ("InitAchievements.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.achievement;
@ -17,20 +17,20 @@ import net.minecraftforge.common.AchievementPage;
import java.util.ArrayList;
public class InitAchievements{
public final class InitAchievements{
public static final ArrayList<Achievement> ACHIEVEMENT_LIST = new ArrayList<Achievement>();
public static int pageNumber;
public static AchievementPage theAchievementPage;
public static ArrayList<Achievement> achievementList = new ArrayList<Achievement>();
public static void init(){
ModUtil.LOGGER.info("Initializing Achievements...");
for(int i = 0; i < TheAchievements.values().length; i++){
achievementList.add(TheAchievements.values()[i].ach);
ACHIEVEMENT_LIST.add(TheAchievements.values()[i].chieve);
}
theAchievementPage = new AchievementPage(StringUtil.localize("achievement.page."+ModUtil.MOD_ID_LOWER), achievementList.toArray(new Achievement[achievementList.size()]));
theAchievementPage = new AchievementPage(StringUtil.localize("achievement.page."+ModUtil.MOD_ID), ACHIEVEMENT_LIST.toArray(new Achievement[ACHIEVEMENT_LIST.size()]));
pageNumber = AchievementPage.getAchievementPages().size();
AchievementPage.registerAchievementPage(theAchievementPage);
}

View file

@ -1,26 +1,28 @@
/*
* This file ("TheAchievements.java") is part of the Actually Additions Mod for Minecraft.
* This file ("TheAchievements.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.achievement;
import de.ellpeck.actuallyadditions.mod.achievement.InitAchievements.Type;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
public enum TheAchievements{
OPEN_BOOKLET("openBooklet", 0, 0, new ItemStack(InitItems.itemBooklet), null, InitAchievements.Type.MISC),
NAME_SMILEY_CLOUD("nameSmileyCloud", 4, 2, new ItemStack(InitBlocks.blockSmileyCloud), null, InitAchievements.Type.MISC, true),
OPEN_TREASURE_CHEST("openTreasureChest", 1, -3, new ItemStack(InitBlocks.blockTreasureChest), OPEN_BOOKLET, InitAchievements.Type.MISC),
OPEN_BOOKLET("openBooklet", 0, 0, new ItemStack(InitItems.itemBooklet), null, Type.MISC),
NAME_SMILEY_CLOUD("nameSmileyCloud", 4, 2, new ItemStack(InitBlocks.blockSmileyCloud), null, Type.MISC, true),
OPEN_TREASURE_CHEST("openTreasureChest", 1, -3, new ItemStack(InitBlocks.blockTreasureChest), OPEN_BOOKLET, Type.MISC),
CRAFT_COAL_GEN("craftCoalGen", -2, 0, new ItemStack(InitBlocks.blockCoalGenerator), OPEN_BOOKLET),
CRAFT_LEAF_GEN("craftLeafGen", -3, -2, new ItemStack(InitBlocks.blockLeafGenerator), CRAFT_COAL_GEN),
CRAFT_RECONSTRUCTOR("craftReconstructor", -5, 0, new ItemStack(InitBlocks.blockAtomicReconstructor), CRAFT_COAL_GEN),
@ -29,29 +31,31 @@ public enum TheAchievements{
CRAFT_ENERGYFACE("craftEnergyface", 2, -2, new ItemStack(InitBlocks.blockPhantomEnergyface), CRAFT_PHANTOMFACE),
CRAFT_LASER_RELAY("craftLaserRelay", -7, -2, new ItemStack(InitBlocks.blockLaserRelay), CRAFT_RECONSTRUCTOR),
CRAFT_CRUSHER("craftCrusher", -8, 0, new ItemStack(InitBlocks.blockGrinder), CRAFT_RECONSTRUCTOR),
PICK_UP_COFFEE("pickUpCoffee", -4, 2, new ItemStack(InitItems.itemCoffeeBean), CRAFT_RECONSTRUCTOR, InitAchievements.Type.PICK_UP),
CRAFT_COFFEE_MACHINE("craftCoffeeMachine", -3, 3, new ItemStack(InitBlocks.blockCoffeeMachine), PICK_UP_COFFEE);
PICK_UP_COFFEE("pickUpCoffee", -4, 2, new ItemStack(InitItems.itemCoffeeBean), CRAFT_RECONSTRUCTOR, Type.PICK_UP),
CRAFT_COFFEE_MACHINE("craftCoffeeMachine", -3, 3, new ItemStack(InitBlocks.blockCoffeeMachine), PICK_UP_COFFEE),
OBSCURED("obscured", 5, -5, new ItemStack(Items.RECORD_11), null, Type.MISC, true),
CRAFT_FIREWORK_BOX("craftFireworkBox", -6, -4, new ItemStack(InitBlocks.blockFireworkBox), null, Type.CRAFTING, true);
public final Achievement ach;
public final InitAchievements.Type type;
public final Achievement chieve;
public final Type type;
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore){
this(name, x, y, displayStack, hasToHaveBefore, InitAchievements.Type.CRAFTING, false);
this(name, x, y, displayStack, hasToHaveBefore, Type.CRAFTING, false);
}
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, InitAchievements.Type type, boolean special){
this.ach = new Achievement("achievement."+ModUtil.MOD_ID_LOWER+"."+name, ModUtil.MOD_ID_LOWER+"."+name, x, y, displayStack, hasToHaveBefore == null ? null : hasToHaveBefore.ach);
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, Type type, boolean special){
this.chieve = new Achievement("achievement."+ModUtil.MOD_ID+"."+name, ModUtil.MOD_ID+"."+name, x, y, displayStack, hasToHaveBefore == null ? null : hasToHaveBefore.chieve);
if(hasToHaveBefore == null){
this.ach.initIndependentStat();
this.chieve.initIndependentStat();
}
if(special){
this.ach.setSpecial();
this.chieve.setSpecial();
}
this.ach.registerStat();
this.chieve.registerStat();
this.type = type;
}
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, InitAchievements.Type type){
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, Type type){
this(name, x, y, displayStack, hasToHaveBefore, type, false);
}
}

View file

@ -1,22 +1,24 @@
/*
* This file ("BlockAtomicReconstructor.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockAtomicReconstructor.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.util.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
@ -24,14 +26,17 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -45,38 +50,45 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 5);
public BlockAtomicReconstructor(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(10F);
this.setResistance(80F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public boolean isOpaqueCube(){
public boolean isOpaqueCube(IBlockState state){
return false;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing par6, float par7, float par8, float par9){
if(this.tryToggleRedstone(world, pos, player)){
return true;
}
if(!world.isRemote){
TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor)world.getTileEntity(pos);
if(reconstructor != null){
ItemStack heldItem = player.getCurrentEquippedItem();
if(heldItem != null){
if(heldItem.getItem() instanceof ILensItem && reconstructor.getStackInSlot(0) == null){
Item item = heldItem.getItem();
if(item instanceof ILensItem && reconstructor.getStackInSlot(0) == null){
ItemStack toPut = heldItem.copy();
toPut.stackSize = 1;
reconstructor.setInventorySlotContents(0, toPut);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
//Shush, don't tell anyone!
else if(item == Items.RECORD_11){
reconstructor.counter++;
reconstructor.markDirty();
player.addStat(TheAchievements.OBSCURED.chieve);
}
}
else{
if(reconstructor.getStackInSlot(0) != null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, reconstructor.getStackInSlot(0).copy());
ItemStack slot = reconstructor.getStackInSlot(0);
if(slot != null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, slot.copy());
reconstructor.setInventorySlotContents(0, null);
}
}
@ -85,6 +97,7 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int i){
return new TileEntityAtomicReconstructor();
@ -98,26 +111,26 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
@Override
@SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, Profiler profiler, ScaledResolution resolution){
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
if(tile instanceof TileEntityAtomicReconstructor){
ItemStack slot = ((TileEntityAtomicReconstructor)tile).getStackInSlot(0);
String strg;
if(slot == null){
strg = StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".noLens");
strg = StringUtil.localize("info."+ModUtil.MOD_ID+".noLens");
}
else{
strg = slot.getItem().getItemStackDisplayName(slot);
AssetUtil.renderStackToGui(slot, resolution.getScaledWidth()/2+15, resolution.getScaledHeight()/2-29, 1F);
}
minecraft.fontRendererObj.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg, resolution.getScaledWidth()/2+35, resolution.getScaledHeight()/2-25, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg, resolution.getScaledWidth()/2+35, resolution.getScaledHeight()/2-25, StringUtil.DECIMAL_COLOR_WHITE);
}
}
@Override
protected Class<? extends ItemBlockBase> getItemBlock(){
return TheItemBlock.class;
protected ItemBlockBase getItemBlock(){
return new TheItemBlock(this);
}
@Override
@ -127,8 +140,8 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
PosUtil.setMetadata(pos, world, rotation, 2);
int rotation = BlockPistonBase.getFacingFromEntity(pos, player).ordinal();
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
}
@ -150,6 +163,7 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
this.setMaxDamage(0);
}
@Override
public String getUnlocalizedName(ItemStack stack){
return this.getUnlocalizedName();
@ -170,7 +184,7 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
this.toPick2 = Util.RANDOM.nextInt(NAME_FLAVOR_AMOUNTS_2)+1;
}
String base = "tile."+ModUtil.MOD_ID_LOWER+"."+((BlockAtomicReconstructor)this.block).getBaseName()+".info.";
String base = "tile."+ModUtil.MOD_ID+"."+((BlockAtomicReconstructor)this.block).getBaseName()+".info.";
list.add(StringUtil.localize(base+"1."+this.toPick1)+" "+StringUtil.localize(base+"2."+this.toPick2));
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockBlackLotus.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockBlackLotus.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;

View file

@ -0,0 +1,166 @@
/*
* This file ("BlockBookletStand.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
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.booklet.entry.EntrySet;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBookletStand;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockBookletStand extends BlockContainerBase implements IHudDisplay{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 3);
private static final AxisAlignedBB AABB_1 = new AxisAlignedBB(0, 3*0.0625, 0, 1, 14*0.0625, 0.0625);
private static final AxisAlignedBB AABB_2 = new AxisAlignedBB(0, 3*0.0625, 0, 0.0625, 14*0.0625, 1);
private static final AxisAlignedBB AABB_3 = new AxisAlignedBB(1-0.0625, 3*0.0625, 0, 1, 14*0.0625, 1);
private static final AxisAlignedBB AABB_4 = new AxisAlignedBB(1, 3*0.0625, 1-0.0625, 0, 14*0.0625, 1);
public BlockBookletStand(String name){
super(Material.WOOD, name);
this.setHarvestLevel("axe", 0);
this.setHardness(1.0F);
this.setResistance(4.0F);
this.setSoundType(SoundType.WOOD);
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
int meta = this.getMetaFromState(state);
switch(meta){
case 0:
return AABB_4;
case 1:
return AABB_1;
case 2:
return AABB_3;
case 3:
return AABB_2;
}
return super.getBoundingBox(state, source, pos);
}
@Override
public boolean isFullCube(IBlockState state){
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
return false;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.BOOK_STAND.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
return true;
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.RARE;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
if(rotation == 0){
world.setBlockState(pos, this.getStateFromMeta(0), 2);
}
if(rotation == 1){
world.setBlockState(pos, this.getStateFromMeta(3), 2);
}
if(rotation == 2){
world.setBlockState(pos, this.getStateFromMeta(1), 2);
}
if(rotation == 3){
world.setBlockState(pos, this.getStateFromMeta(2), 2);
}
TileEntityBookletStand tile = (TileEntityBookletStand)world.getTileEntity(pos);
if(tile != null){
if(tile.assignedPlayer == null){
tile.assignedPlayer = player.getName();
tile.markDirty();
tile.sendUpdate();
}
}
super.onBlockPlacedBy(world, pos, state, player, stack);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityBookletStand();
}
@Override
@SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, Profiler profiler, ScaledResolution resolution){
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
if(tile instanceof TileEntityBookletStand){
EntrySet set = ((TileEntityBookletStand)tile).assignedEntry;
String strg1;
String strg2;
if(set.entry == null){
strg1 = "No entry saved! Save one if";
strg2 = "you are the player who placed it!";
}
else if(set.chapter == null){
strg1 = set.entry.getLocalizedName();
strg2 = "Page "+set.pageInIndex;
}
else{
strg1 = set.chapter.getLocalizedName();
strg2 = "Page "+set.page.getID();
AssetUtil.renderStackToGui(set.chapter.getDisplayItemStack() != null ? set.chapter.getDisplayItemStack() : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+10, 1F);
}
minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg1, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+8, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg2, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+18, StringUtil.DECIMAL_COLOR_WHITE);
}
}
@Override
protected PropertyInteger getMetaProperty(){
return META;
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockBreaker.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockBreaker.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -15,8 +15,9 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlacer;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
@ -25,31 +26,33 @@ 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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockBreaker extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 5);
private boolean isPlacer;
private final boolean isPlacer;
public BlockBreaker(boolean isPlacer, String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.isPlacer = isPlacer;
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return this.isPlacer ? new TileEntityBreaker.TileEntityPlacer() : new TileEntityBreaker();
return this.isPlacer ? new TileEntityPlacer() : new TileEntityBreaker();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(this.tryToggleRedstone(world, pos, player)){
return true;
}
@ -70,8 +73,8 @@ public class BlockBreaker extends BlockContainerBase{
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
PosUtil.setMetadata(pos, world, rotation, 2);
int rotation = BlockPistonBase.getFacingFromEntity(pos, player).ordinal();
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockCanolaPress.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockCanolaPress.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -14,37 +14,42 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockCanolaPress extends BlockContainerBase{
public BlockCanolaPress(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityCanolaPress();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing side, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityCanolaPress press = (TileEntityCanolaPress)world.getTileEntity(pos);
if(press != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.CANOLA_PRESS.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
if(this.checkFailUseItemOnTank(player, stack, press.tank)){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.CANOLA_PRESS.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
return true;
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockCoalGenerator.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockCoalGenerator.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -16,17 +16,17 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -35,17 +35,16 @@ import java.util.Random;
public class BlockCoalGenerator extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 1);
public BlockCoalGenerator(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
this.setTickRandomly(true);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityCoalGenerator();
@ -53,18 +52,19 @@ public class BlockCoalGenerator extends BlockContainerBase{
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
int meta = PosUtil.getMetadata(pos, world);
if(meta == 1){
for(int i = 0; i < 5; i++){
world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : 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){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityCoalGenerator){
if(((TileEntityCoalGenerator)tile).currentBurnTime > 0){
for(int i = 0; i < 5; i++){
world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : 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, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityCoalGenerator press = (TileEntityCoalGenerator)world.getTileEntity(pos);
if(press != null){
@ -80,11 +80,6 @@ public class BlockCoalGenerator extends BlockContainerBase{
return EnumRarity.RARE;
}
@Override
protected PropertyInteger getMetaProperty(){
return META;
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state){
this.dropInventory(world, pos);

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockCoffeeMachine.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockCoffeeMachine.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -14,7 +14,7 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
@ -23,48 +23,58 @@ 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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
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 PropertyInteger META = PropertyInteger.create("meta", 0, 3);
public BlockCoffeeMachine(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
float f = 1/16F;
this.setBlockBounds(f, 0F, f, 1F-f, 1F-2*f, 1F-f);
this.setSoundType(SoundType.STONE);
}
@Override
public boolean isFullCube(){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
return AABB;
}
@Override
public boolean isFullCube(IBlockState state){
return false;
}
@Override
public boolean isOpaqueCube(){
public boolean isOpaqueCube(IBlockState state){
return false;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing f6, float f7, float f8, float f9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing f6, float f7, float f8, float f9){
if(!world.isRemote){
TileEntityCoffeeMachine machine = (TileEntityCoffeeMachine)world.getTileEntity(pos);
if(machine != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.COFFEE_MACHINE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
if(this.checkFailUseItemOnTank(player, stack, machine.tank)){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.COFFEE_MACHINE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
return true;
}
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int meta){
return new TileEntityCoffeeMachine();
@ -86,16 +96,16 @@ public class BlockCoffeeMachine extends BlockContainerBase{
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
if(rotation == 0){
PosUtil.setMetadata(pos, world, 0, 2);
world.setBlockState(pos, this.getStateFromMeta(0), 2);
}
if(rotation == 1){
PosUtil.setMetadata(pos, world, 3, 2);
world.setBlockState(pos, this.getStateFromMeta(3), 2);
}
if(rotation == 2){
PosUtil.setMetadata(pos, world, 1, 2);
world.setBlockState(pos, this.getStateFromMeta(1), 2);
}
if(rotation == 3){
PosUtil.setMetadata(pos, world, 2, 2);
world.setBlockState(pos, this.getStateFromMeta(2), 2);
}
super.onBlockPlacedBy(world, pos, state, player, stack);

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockColoredLamp.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockColoredLamp.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@ -27,9 +26,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
@ -41,12 +40,12 @@ import java.util.Random;
public class BlockColoredLamp extends BlockBase{
public static TheColoredLampColors[] allLampTypes = TheColoredLampColors.values();
private static final PropertyInteger META = PropertyInteger.create("meta", 0, allLampTypes.length-1);
public boolean isOn;
public static final TheColoredLampColors[] ALL_LAMP_TYPES = TheColoredLampColors.values();
private static final PropertyInteger META = PropertyInteger.create("meta", 0, ALL_LAMP_TYPES.length-1);
public final boolean isOn;
public BlockColoredLamp(boolean isOn, String name){
super(Material.redstoneLight, name);
super(Material.REDSTONE_LIGHT, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(0.5F);
this.setResistance(3.0F);
@ -64,16 +63,15 @@ public class BlockColoredLamp extends BlockBase{
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ){
//Turning On
if(player.isSneaking()){
if(!world.isRemote){
PosUtil.setBlock(pos, world, this.isOn ? InitBlocks.blockColoredLamp : InitBlocks.blockColoredLampOn, PosUtil.getMetadata(pos, world), 2);
world.setBlockState(pos, (this.isOn ? InitBlocks.blockColoredLamp : InitBlocks.blockColoredLampOn).getStateFromMeta(this.getMetaFromState(state)), 2);
}
return true;
}
ItemStack stack = player.getCurrentEquippedItem();
if(stack != null){
//Changing Colors
int[] oreIDs = OreDictionary.getOreIDs(stack);
@ -82,9 +80,9 @@ public class BlockColoredLamp extends BlockBase{
String name = OreDictionary.getOreName(oreID);
TheColoredLampColors color = TheColoredLampColors.getColorFromDyeName(name);
if(color != null){
if(PosUtil.getMetadata(pos, world) != color.ordinal()){
if(this.getMetaFromState(state) != color.ordinal()){
if(!world.isRemote){
PosUtil.setMetadata(pos, world, color.ordinal(), 2);
world.setBlockState(pos, this.getStateFromMeta(color.ordinal()), 2);
if(!player.capabilities.isCreativeMode){
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
@ -106,37 +104,27 @@ public class BlockColoredLamp extends BlockBase{
@Override
@SideOnly(Side.CLIENT)
public Item getItem(World world, BlockPos pos){
return Item.getItemFromBlock(InitBlocks.blockColoredLamp);
}
@SuppressWarnings("all")
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list){
for(int j = 0; j < allLampTypes.length; j++){
for(int j = 0; j < ALL_LAMP_TYPES.length; j++){
list.add(new ItemStack(item, 1, j));
}
}
@Override
public int getLightValue(IBlockAccess world, BlockPos pos){
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos){
return this.isOn ? 15 : 0;
}
@Override
public Class<? extends ItemBlockBase> getItemBlock(){
return TheItemBlock.class;
protected ItemBlockBase getItemBlock(){
return new TheItemBlock(this);
}
@Override
protected void registerRendering(){
ResourceLocation[] resLocs = new ResourceLocation[allLampTypes.length];
for(int i = 0; i < allLampTypes.length; i++){
String name = this.getBaseName()+allLampTypes[i].name;
resLocs[i] = new ResourceLocation(ModUtil.MOD_ID_LOWER, name);
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(ModUtil.MOD_ID_LOWER, name));
for(int i = 0; i < ALL_LAMP_TYPES.length; i++){
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), META.getName()+"="+i);
}
ActuallyAdditions.proxy.addRenderVariant(Item.getItemFromBlock(this), resLocs);
}
@Override
@ -157,17 +145,19 @@ public class BlockColoredLamp extends BlockBase{
this.setMaxDamage(0);
}
@Override
public String getItemStackDisplayName(ItemStack stack){
if(stack.getItemDamage() >= allLampTypes.length){
return null;
if(stack.getItemDamage() >= ALL_LAMP_TYPES.length){
return StringUtil.BUGGED_ITEM_NAME;
}
return StringUtil.localize(this.getUnlocalizedName(stack)+".name")+(((BlockColoredLamp)this.block).isOn ? " ("+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".onSuffix.desc")+")" : "");
return StringUtil.localize(this.getUnlocalizedName(stack)+".name")+(((BlockColoredLamp)this.block).isOn ? " ("+StringUtil.localize("tooltip."+ModUtil.MOD_ID+".onSuffix.desc")+")" : "");
}
@Override
public String getUnlocalizedName(ItemStack stack){
return InitBlocks.blockColoredLamp.getUnlocalizedName()+allLampTypes[stack.getItemDamage()].name;
return InitBlocks.blockColoredLamp.getUnlocalizedName()+ALL_LAMP_TYPES[stack.getItemDamage()].name;
}
}
}

View file

@ -1,22 +1,21 @@
/*
* This file ("BlockCompost.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockCompost.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.items.ItemFertilizer;
import de.ellpeck.actuallyadditions.mod.items.ItemMisc;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
@ -27,7 +26,13 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -36,77 +41,104 @@ import java.util.List;
public class BlockCompost extends BlockContainerBase implements IHudDisplay{
protected static final AxisAlignedBB AABB_LEGS = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.3125D, 1.0D);
protected static final AxisAlignedBB AABB_WALL_NORTH = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D);
protected static final AxisAlignedBB AABB_WALL_SOUTH = new AxisAlignedBB(0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D);
protected static final AxisAlignedBB AABB_WALL_EAST = new AxisAlignedBB(0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
protected static final AxisAlignedBB AABB_WALL_WEST = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D);
private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0625, 0, 0.0625, 1-0.0625, 11*0.0625, 1-0.0625);
public BlockCompost(String name){
super(Material.wood, name);
super(Material.WOOD, name);
this.setHarvestLevel("axe", 0);
this.setHardness(0.5F);
this.setResistance(5.0F);
this.setStepSound(soundTypeWood);
this.setBlockBoundsForItemRender();
this.setSoundType(SoundType.WOOD);
}
@Override
public void addCollisionBoxesToList(World world, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity){
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.3125F, 1.0F);
super.addCollisionBoxesToList(world, pos, state, mask, list, collidingEntity);
float f = 0.125F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
super.addCollisionBoxesToList(world, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
super.addCollisionBoxesToList(world, pos, state, mask, list, collidingEntity);
this.setBlockBounds(1.0F-f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
super.addCollisionBoxesToList(world, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 1.0F-f, 1.0F, 1.0F, 1.0F);
super.addCollisionBoxesToList(world, pos, state, mask, list, collidingEntity);
this.setBlockBoundsForItemRender();
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
return AABB;
}
@Override
public boolean isOpaqueCube(){
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn){
addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_LEGS);
addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_WEST);
addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_NORTH);
addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_EAST);
addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_SOUTH);
}
@Override
public boolean isOpaqueCube(IBlockState state){
return false;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing f6, float f7, float f8, float f9){
if(!world.isRemote){
ItemStack stackPlayer = player.getCurrentEquippedItem();
TileEntityCompost tile = (TileEntityCompost)world.getTileEntity(pos);
//Add items to be composted
if(stackPlayer != null && stackPlayer.getItem() instanceof ItemMisc && stackPlayer.getItemDamage() == TheMiscItems.MASHED_FOOD.ordinal() && (tile.slots[0] == null || (!(tile.slots[0].getItem() instanceof ItemFertilizer) && tile.slots[0].stackSize < TileEntityCompost.AMOUNT))){
if(tile.slots[0] == null){
tile.slots[0] = new ItemStack(stackPlayer.getItem(), 1, TheMiscItems.MASHED_FOOD.ordinal());
}
else{
tile.slots[0].stackSize++;
}
if(!player.capabilities.isCreativeMode){
player.inventory.getCurrentItem().stackSize--;
}
tile.markDirty();
}
//Add Fertilizer to player's inventory
else if(tile.slots[0] != null && (stackPlayer == null || (stackPlayer.getItem() instanceof ItemFertilizer && stackPlayer.stackSize <= stackPlayer.getMaxStackSize()-tile.slots[0].stackSize)) && tile.slots[0].getItem() instanceof ItemFertilizer){
if(stackPlayer == null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, tile.slots[0].copy());
}
else{
player.getCurrentEquippedItem().stackSize += tile.slots[0].stackSize;
}
tile.slots[0] = null;
tile.markDirty();
}
}
return true;
public boolean isFullCube(IBlockState state){
return false;
}
@Override
public void setBlockBoundsForItemRender(){
float f = 1.0F/16.0F;
this.setBlockBounds(f, 0.0F, f, 1.0F-f, 1.0F, 1.0F-f);
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stackPlayer, EnumFacing f6, float f7, float f8, float f9){
if(!world.isRemote){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityCompost){
TileEntityCompost compost = (TileEntityCompost)tile;
ItemStack slot = compost.getStackInSlot(0);
CompostRecipe recipeIn = TileEntityCompost.getRecipeForInput(slot);
if(slot == null || recipeIn != null){
if(stackPlayer != null){
CompostRecipe recipeHand = TileEntityCompost.getRecipeForInput(stackPlayer);
if(recipeHand != null && (recipeIn == null || recipeIn == recipeHand)){
int maxAdd = Math.min(recipeHand.input.stackSize, stackPlayer.stackSize);
if(slot == null){
ItemStack stackToAdd = stackPlayer.copy();
stackToAdd.stackSize = maxAdd;
compost.setInventorySlotContents(0, stackToAdd);
player.inventory.decrStackSize(player.inventory.currentItem, maxAdd);
return true;
}
else{
ItemStack stackIn = slot.copy();
if(stackIn.stackSize < recipeHand.input.stackSize){
int sizeAdded = Math.min(maxAdd, recipeHand.input.stackSize-stackIn.stackSize);
stackIn.stackSize += sizeAdded;
compost.setInventorySlotContents(0, stackIn);
player.inventory.decrStackSize(player.inventory.currentItem, sizeAdded);
return true;
}
}
}
}
}
else{
if(stackPlayer == null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, slot.copy());
compost.setInventorySlotContents(0, null);
return true;
}
else if(stackPlayer.isItemEqual(slot)){
int addedStackSize = Math.min(slot.stackSize, stackPlayer.getMaxStackSize()-stackPlayer.stackSize);
ItemStack stackToAdd = stackPlayer.copy();
stackToAdd.stackSize += addedStackSize;
player.inventory.setInventorySlotContents(player.inventory.currentItem, stackToAdd);
compost.decrStackSize(0, addedStackSize);
return true;
}
}
}
}
else{
return true;
}
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int meta){
return new TileEntityCompost();
@ -125,7 +157,7 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
@Override
@SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, Profiler profiler, ScaledResolution resolution){
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
if(tile instanceof TileEntityCompost){
ItemStack slot = ((TileEntityCompost)tile).getStackInSlot(0);
@ -138,7 +170,7 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
AssetUtil.renderStackToGui(slot, resolution.getScaledWidth()/2+15, resolution.getScaledHeight()/2-29, 1F);
}
minecraft.fontRendererObj.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg, resolution.getScaledWidth()/2+35, resolution.getScaledHeight()/2-25, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg, resolution.getScaledWidth()/2+35, resolution.getScaledHeight()/2-25, StringUtil.DECIMAL_COLOR_WHITE);
}
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockCrystal.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockCrystal.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@ -24,7 +23,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -32,11 +30,11 @@ import java.util.List;
public class BlockCrystal extends BlockBase{
public static final TheCrystals[] allCrystals = TheCrystals.values();
private static final PropertyInteger META = PropertyInteger.create("meta", 0, allCrystals.length-1);
public static final TheCrystals[] ALL_CRYSTALS = TheCrystals.values();
private static final PropertyInteger META = PropertyInteger.create("meta", 0, ALL_CRYSTALS.length-1);
public BlockCrystal(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setHarvestLevel("pickaxe", 1);
@ -47,33 +45,29 @@ public class BlockCrystal extends BlockBase{
return this.getMetaFromState(state);
}
@SuppressWarnings("all")
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list){
for(int j = 0; j < allCrystals.length; j++){
for(int j = 0; j < ALL_CRYSTALS.length; j++){
list.add(new ItemStack(item, 1, j));
}
}
@Override
public Class<? extends ItemBlockBase> getItemBlock(){
return TheItemBlock.class;
protected ItemBlockBase getItemBlock(){
return new TheItemBlock(this);
}
@Override
protected void registerRendering(){
ResourceLocation[] resLocs = new ResourceLocation[allCrystals.length];
for(int i = 0; i < allCrystals.length; i++){
String name = this.getBaseName()+allCrystals[i].name;
resLocs[i] = new ResourceLocation(ModUtil.MOD_ID_LOWER, name);
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(ModUtil.MOD_ID_LOWER, name));
for(int i = 0; i < ALL_CRYSTALS.length; i++){
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), META.getName()+"="+i);
}
ActuallyAdditions.proxy.addRenderVariant(Item.getItemFromBlock(this), resLocs);
}
@Override
public EnumRarity getRarity(ItemStack stack){
return stack.getItemDamage() >= allCrystals.length ? EnumRarity.COMMON : allCrystals[stack.getItemDamage()].rarity;
return stack.getItemDamage() >= ALL_CRYSTALS.length ? EnumRarity.COMMON : ALL_CRYSTALS[stack.getItemDamage()].rarity;
}
@Override
@ -89,9 +83,10 @@ public class BlockCrystal extends BlockBase{
this.setMaxDamage(0);
}
@Override
public String getUnlocalizedName(ItemStack stack){
return stack.getItemDamage() >= allCrystals.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+allCrystals[stack.getItemDamage()].name;
return stack.getItemDamage() >= ALL_CRYSTALS.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+ALL_CRYSTALS[stack.getItemDamage()].name;
}
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockDirectionalBreaker.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockDirectionalBreaker.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -15,8 +15,8 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
@ -25,8 +25,9 @@ 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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockDirectionalBreaker extends BlockContainerBase{
@ -34,20 +35,21 @@ public class BlockDirectionalBreaker extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 5);
public BlockDirectionalBreaker(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityDirectionalBreaker();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(this.tryToggleRedstone(world, pos, player)){
return true;
}
@ -68,8 +70,8 @@ public class BlockDirectionalBreaker extends BlockContainerBase{
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
PosUtil.setMetadata(pos, world, rotation, 2);
int rotation = BlockPistonBase.getFacingFromEntity(pos, player).ordinal();
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
}

View file

@ -0,0 +1,88 @@
/*
* This file ("BlockDisplayStand.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
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.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockDisplayStand extends BlockContainerBase{
public BlockDisplayStand(String name){
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta){
return new TileEntityDisplayStand();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityDisplayStand stand = (TileEntityDisplayStand)world.getTileEntity(pos);
if(stand != null){
ItemStack display = stand.getStackInSlot(0);
if(heldItem != null){
if(display == null){
ItemStack toPut = heldItem.copy();
toPut.stackSize = 1;
stand.setInventorySlotContents(0, toPut);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
return true;
}
}
else{
if(display != null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, display.copy());
stand.setInventorySlotContents(0, null);
return true;
}
}
}
return false;
}
else{
return true;
}
}
@Override
public boolean isOpaqueCube(IBlockState state){
return false;
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state){
this.dropInventory(worldIn, pos);
super.breakBlock(worldIn, pos, state);
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.RARE;
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockDropper.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockDropper.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -14,8 +14,8 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
@ -24,8 +24,9 @@ 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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockDropper extends BlockContainerBase{
@ -33,20 +34,21 @@ public class BlockDropper extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 5);
public BlockDropper(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityDropper();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(this.tryToggleRedstone(world, pos, player)){
return true;
}
@ -67,8 +69,8 @@ public class BlockDropper extends BlockContainerBase{
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
PosUtil.setMetadata(pos, world, rotation, 2);
int rotation = BlockPistonBase.getFacingFromEntity(pos, player).ordinal();
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockEnergizer.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockEnergizer.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -15,36 +15,39 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockEnergizer extends BlockContainerBase{
private boolean isEnergizer;
private final boolean isEnergizer;
public BlockEnergizer(boolean isEnergizer, String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.isEnergizer = isEnergizer;
this.setHarvestLevel("pickaxe", 0);
this.setHardness(2.0F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
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, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
if(this.isEnergizer){
TileEntityEnergizer energizer = (TileEntityEnergizer)world.getTileEntity(pos);

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockFeeder.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockFeeder.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -14,33 +14,36 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFeeder;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockFeeder extends BlockContainerBase{
public BlockFeeder(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(0.5F);
this.setResistance(6.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityFeeder();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityFeeder feeder = (TileEntityFeeder)world.getTileEntity(pos);
if(feeder != null){

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockFermentingBarrel.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockFermentingBarrel.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -14,26 +14,29 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFermentingBarrel;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockFermentingBarrel extends BlockContainerBase{
public BlockFermentingBarrel(String name){
super(Material.wood, name);
super(Material.WOOD, name);
this.setHarvestLevel("axe", 0);
this.setHardness(0.5F);
this.setResistance(5.0F);
this.setStepSound(soundTypeWood);
this.setSoundType(SoundType.WOOD);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityFermentingBarrel();
@ -46,11 +49,13 @@ public class BlockFermentingBarrel extends BlockContainerBase{
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityFermentingBarrel press = (TileEntityFermentingBarrel)world.getTileEntity(pos);
if(press != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FERMENTING_BARREL.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
if(this.checkFailUseItemOnTank(player, heldItem, press.canolaTank) && this.checkFailUseItemOnTank(player, heldItem, press.oilTank)){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FERMENTING_BARREL.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
return true;
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockFireworkBox.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockFireworkBox.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -13,33 +13,36 @@ package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockFireworkBox extends BlockContainerBase{
public BlockFireworkBox(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityFireworkBox();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
return this.tryToggleRedstone(world, pos, player);
}

View file

@ -1,46 +1,58 @@
/*
* This file ("BlockFishingNet.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockFishingNet.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFishingNet;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockFishingNet extends BlockContainerBase{
private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 1, 0.0625, 1);
public BlockFishingNet(String name){
super(Material.wood, name);
super(Material.WOOD, name);
this.setHarvestLevel("axe", 0);
this.setHardness(0.5F);
this.setResistance(3.0F);
this.setStepSound(soundTypeWood);
this.setBlockBounds(0F, 0F, 0F, 1F, 1F/16F, 1F);
this.setSoundType(SoundType.WOOD);
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
return AABB;
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityFishingNet();
}
@Override
public boolean isFullCube(){
public boolean isFullCube(IBlockState state){
return false;
}
@Override
public boolean isOpaqueCube(){
public boolean isOpaqueCube(IBlockState state){
return false;
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockFluidCollector.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockFluidCollector.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -15,8 +15,9 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidCollector;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidPlacer;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
@ -25,39 +26,43 @@ 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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockFluidCollector extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 5);
private boolean isPlacer;
private final boolean isPlacer;
public BlockFluidCollector(boolean isPlacer, String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.isPlacer = isPlacer;
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return this.isPlacer ? new TileEntityFluidCollector.TileEntityFluidPlacer() : new TileEntityFluidCollector();
return this.isPlacer ? new TileEntityFluidPlacer() : new TileEntityFluidCollector();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, 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){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FLUID_COLLECTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
if(this.checkFailUseItemOnTank(player, stack, collector.tank)){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FLUID_COLLECTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
return true;
}
@ -71,8 +76,8 @@ public class BlockFluidCollector extends BlockContainerBase{
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
PosUtil.setMetadata(pos, world, rotation, 2);
int rotation = BlockPistonBase.getFacingFromEntity(pos, player).ordinal();
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockFurnaceDouble.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockFurnaceDouble.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -15,7 +15,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceDouble;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
@ -24,10 +24,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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
@ -40,14 +41,15 @@ public class BlockFurnaceDouble extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 7);
public BlockFurnaceDouble(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
this.setTickRandomly(true);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityFurnaceDouble();
@ -55,8 +57,8 @@ public class BlockFurnaceDouble extends BlockContainerBase{
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
int meta = PosUtil.getMetadata(pos, world);
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){
int meta = this.getMetaFromState(state);
if(meta > 3){
float f = (float)pos.getX()+0.5F;
@ -89,7 +91,7 @@ public class BlockFurnaceDouble extends BlockContainerBase{
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityFurnaceDouble furnace = (TileEntityFurnaceDouble)world.getTileEntity(pos);
if(furnace != null){
@ -101,8 +103,8 @@ public class BlockFurnaceDouble extends BlockContainerBase{
}
@Override
public int getLightValue(IBlockAccess world, BlockPos pos){
return PosUtil.getMetadata(pos, world) > 3 ? 12 : 0;
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos){
return this.getMetaFromState(state) > 3 ? 12 : 0;
}
@Override
@ -115,16 +117,16 @@ public class BlockFurnaceDouble extends BlockContainerBase{
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
if(rotation == 0){
PosUtil.setMetadata(pos, world, 0, 2);
world.setBlockState(pos, this.getStateFromMeta(0), 2);
}
if(rotation == 1){
PosUtil.setMetadata(pos, world, 3, 2);
world.setBlockState(pos, this.getStateFromMeta(3), 2);
}
if(rotation == 2){
PosUtil.setMetadata(pos, world, 1, 2);
world.setBlockState(pos, this.getStateFromMeta(1), 2);
}
if(rotation == 3){
PosUtil.setMetadata(pos, world, 2, 2);
world.setBlockState(pos, this.getStateFromMeta(2), 2);
}
super.onBlockPlacedBy(world, pos, state, player, stack);

View file

@ -1,46 +1,58 @@
/*
* This file ("BlockFurnaceSolar.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockFurnaceSolar.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceSolar;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockFurnaceSolar extends BlockContainerBase{
private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 1, 6*0.0625, 1);
public BlockFurnaceSolar(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setBlockBounds(0F, 0F, 0F, 1F, 6F/16F, 1F);
this.setSoundType(SoundType.STONE);
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
return AABB;
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityFurnaceSolar();
}
@Override
public boolean isFullCube(){
public boolean isFullCube(IBlockState state){
return false;
}
@Override
public boolean isOpaqueCube(){
public boolean isOpaqueCube(IBlockState state){
return false;
}

View file

@ -1,16 +1,17 @@
/*
* This file ("BlockGeneric.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockGeneric.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
@ -18,11 +19,15 @@ import net.minecraft.item.ItemStack;
public class BlockGeneric extends BlockBase{
public BlockGeneric(String name){
super(Material.rock, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
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){
super(material, name);
this.setHarvestLevel(harvestTool, harvestLevel);
this.setHardness(hardness);
this.setResistance(resistance);
this.setSoundType(sound);
}
@Override

View file

@ -1,21 +1,26 @@
/*
* This file ("BlockGiantChest.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockGiantChest.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
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.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
@ -25,30 +30,42 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class BlockGiantChest extends BlockContainerBase{
public BlockGiantChest(String name){
super(Material.wood, name);
public final int type;
public BlockGiantChest(String name, int type){
super(Material.WOOD, name);
this.type = type;
this.setHarvestLevel("axe", 0);
this.setHardness(0.5F);
this.setResistance(15.0F);
this.setStepSound(soundTypeWood);
this.setSoundType(SoundType.WOOD);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityGiantChest();
switch(this.type){
case 1: return new TileEntityGiantChestMedium();
case 2: return new TileEntityGiantChestLarge();
default: return new TileEntityGiantChest();
}
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityGiantChest chest = (TileEntityGiantChest)world.getTileEntity(pos);
if(chest != null){
@ -73,7 +90,10 @@ public class BlockGiantChest extends BlockContainerBase{
ItemStack[] slots = ((TileEntityGiantChest)tile).slots;
for(int i = 0; i < list.tagCount(); i++){
slots[i] = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i));
NBTTagCompound compound = list.getCompoundTagAt(i);
if(compound != null && compound.hasKey("id")){
slots[i] = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i));
}
}
}
}
@ -81,6 +101,7 @@ public class BlockGiantChest extends BlockContainerBase{
super.onBlockPlacedBy(world, pos, state, entity, stack);
}
@Override
public ArrayList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune){
ArrayList<ItemStack> drops = super.getDrops(world, pos, state, fortune);
@ -94,9 +115,11 @@ public class BlockGiantChest extends BlockContainerBase{
for(int i = 0; i < slots.length; i++){
//Destroy the keeper
if(i != place){
NBTTagCompound compound = new NBTTagCompound();
if(slots[i] != null){
list.appendTag(slots[i].writeToNBT(new NBTTagCompound()));
slots[i].writeToNBT(compound);
}
list.appendTag(compound);
}
}
@ -126,4 +149,27 @@ public class BlockGiantChest extends BlockContainerBase{
super.breakBlock(world, pos, state);
}
@Override
protected ItemBlockBase getItemBlock(){
return new TheItemBlock(this);
}
public static class TheItemBlock extends ItemBlockBase{
public TheItemBlock(Block block){
super(block);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced){
int type = this.block instanceof BlockGiantChest ? ((BlockGiantChest)this.block).type : -1;
if(type == 2){
tooltip.add(TextFormatting.ITALIC+"Supersolid");
}
else if(type == 0){
tooltip.add(TextFormatting.ITALIC+"'Small'");
}
}
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockGreenhouseGlass.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockGreenhouseGlass.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -13,14 +13,15 @@ package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGreenhouseGlass;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
@ -29,36 +30,37 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockGreenhouseGlass extends BlockContainerBase{
public BlockGreenhouseGlass(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(0.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public boolean isFullCube(){
public boolean isFullCube(IBlockState state){
return false;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side){
IBlockState state = worldIn.getBlockState(pos);
Block block = state.getBlock();
return worldIn.getBlockState(pos.offset(side.getOpposite())) != state || block != this && block != this && super.shouldSideBeRendered(worldIn, pos, side);
public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side){
IBlockState otherState = world.getBlockState(pos.offset(side));
Block block = otherState.getBlock();
return state != otherState || block != this && super.shouldSideBeRendered(state, world, pos, side);
}
@Override
public boolean isOpaqueCube(){
public boolean isOpaqueCube(IBlockState state){
return false;
}
@Override
@SideOnly(Side.CLIENT)
public EnumWorldBlockLayer getBlockLayer(){
return EnumWorldBlockLayer.CUTOUT;
public BlockRenderLayer getBlockLayer(){
return BlockRenderLayer.CUTOUT;
}
@Override

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockGrinder.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockGrinder.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -15,7 +15,8 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinderDouble;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
@ -23,9 +24,10 @@ 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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
@ -39,24 +41,25 @@ public class BlockGrinder extends BlockContainerBase{
private final boolean isDouble;
public BlockGrinder(boolean isDouble, String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.isDouble = isDouble;
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
this.setTickRandomly(true);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return this.isDouble ? new TileEntityGrinder.TileEntityGrinderDouble() : new TileEntityGrinder();
return this.isDouble ? new TileEntityGrinderDouble() : new TileEntityGrinder();
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
int meta = PosUtil.getMetadata(pos, world);
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){
int meta = this.getMetaFromState(state);
if(meta == 1){
for(int i = 0; i < 5; i++){
@ -69,7 +72,7 @@ public class BlockGrinder extends BlockContainerBase{
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityGrinder grinder = (TileEntityGrinder)world.getTileEntity(pos);
if(grinder != null){
@ -81,8 +84,8 @@ public class BlockGrinder extends BlockContainerBase{
}
@Override
public int getLightValue(IBlockAccess world, BlockPos pos){
return PosUtil.getMetadata(pos, world) == 1 ? 12 : 0;
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos){
return this.getMetaFromState(state) == 1 ? 12 : 0;
}
@Override

View file

@ -1,17 +1,18 @@
/*
* This file ("BlockHeatCollector.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockHeatCollector.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityHeatCollector;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
@ -21,13 +22,14 @@ import net.minecraft.world.World;
public class BlockHeatCollector extends BlockContainerBase{
public BlockHeatCollector(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(2.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityHeatCollector();

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockInputter.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockInputter.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -16,44 +16,48 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInputter;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInputterAdvanced;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockInputter extends BlockContainerBase{
public static final int NAME_FLAVOR_AMOUNTS = 15;
public boolean isAdvanced;
public final boolean isAdvanced;
public BlockInputter(boolean isAdvanced, String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
this.setTickRandomly(true);
this.isAdvanced = isAdvanced;
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return this.isAdvanced ? new TileEntityInputter.TileEntityInputterAdvanced() : new TileEntityInputter();
return this.isAdvanced ? new TileEntityInputterAdvanced() : new TileEntityInputter();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityInputter inputter = (TileEntityInputter)world.getTileEntity(pos);
if(inputter != null){
@ -77,8 +81,8 @@ public class BlockInputter extends BlockContainerBase{
}
@Override
public Class<? extends ItemBlockBase> getItemBlock(){
return TheItemBlock.class;
protected ItemBlockBase getItemBlock(){
return new TheItemBlock(this);
}
@Override
@ -86,6 +90,16 @@ public class BlockInputter extends BlockContainerBase{
return EnumRarity.EPIC;
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block){
if(!world.isRemote){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityInputter){
((TileEntityInputter)tile).initVars();
}
}
}
public static class TheItemBlock extends ItemBlockBase{
private long lastSysTime;
@ -97,6 +111,7 @@ public class BlockInputter extends BlockContainerBase{
this.setMaxDamage(0);
}
@Override
public String getUnlocalizedName(ItemStack stack){
return this.getUnlocalizedName();
@ -107,6 +122,7 @@ public class BlockInputter extends BlockContainerBase{
return damage;
}
@Override
public String getItemStackDisplayName(ItemStack stack){
long sysTime = System.currentTimeMillis();
@ -116,7 +132,7 @@ public class BlockInputter extends BlockContainerBase{
this.toPick = Util.RANDOM.nextInt(NAME_FLAVOR_AMOUNTS)+1;
}
return StringUtil.localize(this.getUnlocalizedName()+".name")+" ("+StringUtil.localize("tile."+ModUtil.MOD_ID_LOWER+".blockInputter.add."+this.toPick+".name")+")";
return StringUtil.localize(this.getUnlocalizedName()+".name")+" ("+StringUtil.localize("tile."+ModUtil.MOD_ID+".blockInputter.add."+this.toPick+".name")+")";
}
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockItemRepairer.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockItemRepairer.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -15,36 +15,38 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemRepairer;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockItemRepairer extends BlockContainerBase{
public BlockItemRepairer(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(20.0F);
this.setResistance(15.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
this.setTickRandomly(true);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityItemRepairer();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityItemRepairer repairer = (TileEntityItemRepairer)world.getTileEntity(pos);
if(repairer != null){
@ -56,8 +58,8 @@ public class BlockItemRepairer extends BlockContainerBase{
}
@Override
public int getLightValue(IBlockAccess world, BlockPos pos){
return PosUtil.getMetadata(pos, world) == 1 ? 12 : 0;
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos){
return this.getMetaFromState(state) == 1 ? 12 : 0;
}
@Override

View file

@ -0,0 +1,55 @@
/*
* This file ("BlockItemViewer.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockItemViewer extends BlockContainerBase{
public BlockItemViewer(String name){
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setSoundType(SoundType.STONE);
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block){
if(!world.isRemote){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityItemViewer){
((TileEntityItemViewer)tile).saveConnectedRelay();
}
}
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta){
return new TileEntityItemViewer();
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.RARE;
}
}

View file

@ -1,28 +1,28 @@
/*
* This file ("BlockLampPowerer.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockLampPowerer.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockLampPowerer extends BlockBase{
@ -30,16 +30,16 @@ public class BlockLampPowerer extends BlockBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 5);
public BlockLampPowerer(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock){
this.updateLamp(world, pos);
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn){
this.updateLamp(worldIn, pos);
}
@Override
@ -49,24 +49,27 @@ public class BlockLampPowerer extends BlockBase{
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
PosUtil.setMetadata(pos, world, rotation, 2);
int rotation = BlockPistonBase.getFacingFromEntity(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){
BlockPos coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionByPistonRotation(PosUtil.getMetadata(pos, world)), pos, 0);
if(coords != null && PosUtil.getBlock(coords, world) instanceof BlockColoredLamp){
IBlockState state = world.getBlockState(pos);
BlockPos coords = pos.offset(WorldUtil.getDirectionByPistonRotation(state.getBlock().getMetaFromState(state)));
IBlockState coordsState = world.getBlockState(coords);
if(coordsState.getBlock() instanceof BlockColoredLamp){
int meta = coordsState.getBlock().getMetaFromState(coordsState);
if(world.isBlockIndirectlyGettingPowered(pos) > 0){
if(!((BlockColoredLamp)PosUtil.getBlock(coords, world)).isOn){
PosUtil.setBlock(coords, world, InitBlocks.blockColoredLampOn, PosUtil.getMetadata(coords, world), 2);
if(!((BlockColoredLamp)coordsState.getBlock()).isOn){
world.setBlockState(coords, InitBlocks.blockColoredLampOn.getStateFromMeta(meta), 2);
}
}
else{
if(((BlockColoredLamp)PosUtil.getBlock(coords, world)).isOn){
PosUtil.setBlock(coords, world, InitBlocks.blockColoredLamp, PosUtil.getMetadata(coords, world), 2);
if(((BlockColoredLamp)coordsState.getBlock()).isOn){
world.setBlockState(coords, InitBlocks.blockColoredLamp.getStateFromMeta(meta), 2);
}
}
}

View file

@ -1,92 +1,97 @@
/*
* This file ("BlockLaserRelay.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockLaserRelay.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
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;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItem;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemWhitelist;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
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.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.List;
public class BlockLaserRelay extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 5);
//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, 1-F, 1-2*F);
private static final AxisAlignedBB AABB_DOWN = new AxisAlignedBB(2*F, F, 2*F, 1-2*F, 1, 1-2*F);
private static final AxisAlignedBB AABB_NORTH = new AxisAlignedBB(2*F, F, F, 1-2*F, 1-F, 1);
private static final AxisAlignedBB AABB_EAST = new AxisAlignedBB(0, F, 2*F, 1-F, 1-F, 1-2*F);
private static final AxisAlignedBB AABB_SOUTH = new AxisAlignedBB(2*F, F, 0, 1-2*F, 1-F, 1-F);
private static final AxisAlignedBB AABB_WEST = new AxisAlignedBB(F, F, 2*F, 1, 1-F, 1-2*F);
public BlockLaserRelay(String name){
super(Material.rock, name);
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 5);
private final Type type;
public BlockLaserRelay(String name, Type type){
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
this.type = type;
}
@Override
public boolean isFullCube(){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
switch(this.getMetaFromState(state)){
case 1:
return AABB_UP;
case 2:
return AABB_NORTH;
case 3:
return AABB_SOUTH;
case 4:
return AABB_WEST;
case 5:
return AABB_EAST;
default:
return AABB_DOWN;
}
}
@Override
public boolean isFullCube(IBlockState state){
return false;
}
@Override
public void addCollisionBoxesToList(World world, BlockPos pos, IBlockState state, AxisAlignedBB axis, List list, Entity entity){
this.setBlockBoundsBasedOnState(world, pos);
super.addCollisionBoxesToList(world, pos, state, axis, list, entity);
}
@Override
public boolean isOpaqueCube(){
public boolean isOpaqueCube(IBlockState state){
return false;
}
@Override
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase base){
return this.getStateFromMeta(side.ordinal());
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos){
int meta = PosUtil.getMetadata(pos, world);
float pixel = 1F/16F;
if(meta == 0){
this.setBlockBounds(3*pixel, 3*pixel, 3*pixel, 1F-3*pixel, 1F, 1F-3*pixel);
}
else if(meta == 1){
this.setBlockBounds(3*pixel, 0F, 3*pixel, 1F-3*pixel, 1F-3*pixel, 1F-3*pixel);
}
else if(meta == 2){
this.setBlockBounds(3*pixel, 3*pixel, 3*pixel, 1F-3*pixel, 1F-3*pixel, 1F);
}
else if(meta == 3){
this.setBlockBounds(3*pixel, 3*pixel, 0F, 1F-3*pixel, 1F-3*pixel, 1F-3*pixel);
}
else if(meta == 4){
this.setBlockBounds(3*pixel, 3*pixel, 3*pixel, 1F, 1F-3*pixel, 1F-3*pixel);
}
else if(meta == 5){
this.setBlockBounds(0F, 3*pixel, 3*pixel, 1F-3*pixel, 1F-3*pixel, 1F-3*pixel);
}
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.EPIC;
@ -97,8 +102,45 @@ public class BlockLaserRelay extends BlockContainerBase{
return META;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(player.isSneaking()){
TileEntityLaserRelay relay = (TileEntityLaserRelay)world.getTileEntity(pos);
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;
}
}
return false;
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block){
if(!world.isRemote){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityLaserRelay){
((TileEntityLaserRelay)tile).saveAllHandlersAround();
}
}
}
@Override
public TileEntity createNewTileEntity(World world, int i){
return new TileEntityLaserRelay();
switch(this.type){
case ITEM:
return new TileEntityLaserRelayItem();
case ITEM_WHITELIST:
return new TileEntityLaserRelayItemWhitelist();
default:
return new TileEntityLaserRelayEnergy();
}
}
public enum Type{
ENERGY,
ITEM,
ITEM_WHITELIST
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockLavaFactoryController.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockLavaFactoryController.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLavaFactoryController;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
@ -22,7 +23,7 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -30,13 +31,14 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockLavaFactoryController extends BlockContainerBase implements IHudDisplay{
public BlockLavaFactoryController(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(4.5F);
this.setResistance(20.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityLavaFactoryController();
@ -49,15 +51,15 @@ public class BlockLavaFactoryController extends BlockContainerBase implements IH
@Override
@SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, Profiler profiler, ScaledResolution resolution){
TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController)minecraft.theWorld.getTileEntity(posHit.getBlockPos());
if(factory != null){
int state = factory.isMultiblock();
if(state == TileEntityLavaFactoryController.NOT_MULTI){
StringUtil.drawSplitString(minecraft.fontRendererObj, StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.notPart.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
StringUtil.drawSplitString(minecraft.fontRendererObj, StringUtil.localize("tooltip."+ModUtil.MOD_ID+".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.fontRendererObj, StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.works.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
StringUtil.drawSplitString(minecraft.fontRendererObj, StringUtil.localize("tooltip."+ModUtil.MOD_ID+".factory.works.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
}
}
}

View file

@ -1,35 +1,37 @@
/*
* This file ("BlockLeafGenerator.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockLeafGenerator.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLeafGenerator;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockLeafGenerator extends BlockContainerBase{
public BlockLeafGenerator(String name){
super(Material.iron, name);
super(Material.IRON, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(5.0F);
this.setResistance(10.0F);
this.setStepSound(soundTypeMetal);
this.setSoundType(SoundType.METAL);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityLeafGenerator();

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockMiner.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockMiner.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityMiner;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
@ -25,9 +26,10 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -35,20 +37,20 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockMiner extends BlockContainerBase implements IHudDisplay{
public BlockMiner(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(8F);
this.setResistance(30F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public boolean isOpaqueCube(){
public boolean isOpaqueCube(IBlockState state){
return false;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityMiner){
@ -63,6 +65,7 @@ public class BlockMiner extends BlockContainerBase implements IHudDisplay{
return EnumRarity.RARE;
}
@Override
public TileEntity createNewTileEntity(World world, int i){
return new TileEntityMiner();
@ -76,7 +79,7 @@ public class BlockMiner extends BlockContainerBase implements IHudDisplay{
@Override
@SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, Profiler profiler, ScaledResolution resolution){
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
if(tile instanceof TileEntityMiner){
String info = ((TileEntityMiner)tile).layerAt <= 0 ? "Done Mining!" : "Mining at Y = "+((TileEntityMiner)tile).layerAt+".";

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockMisc.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockMisc.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@ -24,7 +23,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -32,11 +30,11 @@ import java.util.List;
public class BlockMisc extends BlockBase{
public static final TheMiscBlocks[] allMiscBlocks = TheMiscBlocks.values();
private static final PropertyInteger META = PropertyInteger.create("meta", 0, allMiscBlocks.length-1);
public static final TheMiscBlocks[] ALL_MISC_BLOCKS = TheMiscBlocks.values();
private static final PropertyInteger META = PropertyInteger.create("meta", 0, ALL_MISC_BLOCKS.length-1);
public BlockMisc(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setHarvestLevel("pickaxe", 1);
@ -47,33 +45,29 @@ public class BlockMisc extends BlockBase{
return this.getMetaFromState(state);
}
@SuppressWarnings("all")
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list){
for(int j = 0; j < allMiscBlocks.length; j++){
for(int j = 0; j < ALL_MISC_BLOCKS.length; j++){
list.add(new ItemStack(item, 1, j));
}
}
@Override
public Class<? extends ItemBlockBase> getItemBlock(){
return TheItemBlock.class;
protected ItemBlockBase getItemBlock(){
return new TheItemBlock(this);
}
@Override
protected void registerRendering(){
ResourceLocation[] resLocs = new ResourceLocation[allMiscBlocks.length];
for(int i = 0; i < allMiscBlocks.length; i++){
String name = this.getBaseName()+allMiscBlocks[i].name;
resLocs[i] = new ResourceLocation(ModUtil.MOD_ID_LOWER, name);
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(ModUtil.MOD_ID_LOWER, name));
for(int i = 0; i < ALL_MISC_BLOCKS.length; i++){
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), META.getName()+"="+i);
}
ActuallyAdditions.proxy.addRenderVariant(Item.getItemFromBlock(this), resLocs);
}
@Override
public EnumRarity getRarity(ItemStack stack){
return stack.getItemDamage() >= allMiscBlocks.length ? EnumRarity.COMMON : allMiscBlocks[stack.getItemDamage()].rarity;
return stack.getItemDamage() >= ALL_MISC_BLOCKS.length ? EnumRarity.COMMON : ALL_MISC_BLOCKS[stack.getItemDamage()].rarity;
}
@Override
@ -89,9 +83,10 @@ public class BlockMisc extends BlockBase{
this.setMaxDamage(0);
}
@Override
public String getUnlocalizedName(ItemStack stack){
return stack.getItemDamage() >= allMiscBlocks.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+allMiscBlocks[stack.getItemDamage()].name;
return stack.getItemDamage() >= ALL_MISC_BLOCKS.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+ALL_MISC_BLOCKS[stack.getItemDamage()].name;
}
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockOilGenerator.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockOilGenerator.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -16,17 +16,17 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -35,17 +35,16 @@ import java.util.Random;
public class BlockOilGenerator extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 1);
public BlockOilGenerator(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
this.setTickRandomly(true);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityOilGenerator();
@ -53,20 +52,25 @@ public class BlockOilGenerator extends BlockContainerBase{
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
if(PosUtil.getMetadata(pos, world) == 1){
for(int i = 0; i < 5; i++){
world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : 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){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityOilGenerator){
if(((TileEntityOilGenerator)tile).currentBurnTime > 0){
for(int i = 0; i < 5; i++){
world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : 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, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityOilGenerator generator = (TileEntityOilGenerator)world.getTileEntity(pos);
if(generator != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.OIL_GENERATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
if(this.checkFailUseItemOnTank(player, stack, generator.tank)){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.OIL_GENERATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
return true;
}
@ -78,11 +82,6 @@ public class BlockOilGenerator extends BlockContainerBase{
return EnumRarity.RARE;
}
@Override
protected PropertyInteger getMetaProperty(){
return META;
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state){
this.dropInventory(world, pos);

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockPhantom.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockPhantom.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -15,8 +15,9 @@ 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.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
@ -27,30 +28,55 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockAccess;
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 Type type;
public int range;
public final Type type;
public BlockPhantom(Type type, String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.type = type;
this.setHarvestLevel("pickaxe", 0);
this.setHardness(4.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
if(type == Type.FACE || type == Type.LIQUIFACE || type == Type.ENERGYFACE){
this.range = TileEntityPhantomface.RANGE;
@Override
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){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityPhantomRedstoneface){
return ((TileEntityPhantomRedstoneface)tile).providesWeak[side.ordinal()];
}
}
else if(type == Type.BREAKER || type == Type.PLACER){
this.range = TileEntityPhantomPlacer.RANGE;
return super.getWeakPower(state, world, pos, side);
}
@Override
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()];
}
}
return super.getStrongPower(state, world, pos, side);
}
@Override
@ -61,24 +87,27 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
super.breakBlock(world, pos, state);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
switch(this.type){
case PLACER:
return new TileEntityPhantomPlacer();
case BREAKER:
return new TileEntityPhantomPlacer.TileEntityPhantomBreaker();
return new TileEntityPhantomBreaker();
case LIQUIFACE:
return new TileEntityPhantomLiquiface();
case ENERGYFACE:
return new TileEntityPhantomEnergyface();
case REDSTONEFACE:
return new TileEntityPhantomRedstoneface();
default:
return new TileEntityPhantomItemface();
}
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ){
if(this.tryToggleRedstone(world, pos, player)){
return true;
}
@ -98,27 +127,29 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
@Override
@SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, Profiler profiler, ScaledResolution resolution){
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
if(tile != null){
if(tile instanceof IPhantomTile){
IPhantomTile phantom = (IPhantomTile)tile;
minecraft.fontRendererObj.drawStringWithShadow(EnumChatFormatting.GOLD+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc")+": "+phantom.getRange(), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-40, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.GOLD+StringUtil.localize("tooltip."+ModUtil.MOD_ID+".blockPhantomRange.desc")+": "+phantom.getRange(), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-40, StringUtil.DECIMAL_COLOR_WHITE);
if(phantom.hasBoundPosition()){
int distance = (int)new Vec3(posHit.getBlockPos()).distanceTo(new Vec3(phantom.getBoundPosition()));
Item item = PosUtil.getItemBlock(phantom.getBoundPosition(), minecraft.theWorld);
String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(PosUtil.getBlock(phantom.getBoundPosition(), minecraft.theWorld), 1, PosUtil.getMetadata(phantom.getBoundPosition(), minecraft.theWorld)));
StringUtil.drawSplitString(minecraft.fontRendererObj, StringUtil.localizeFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".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);
int distance = (int)new Vec3d(posHit.getBlockPos()).distanceTo(new Vec3d(phantom.getBoundPosition()));
IBlockState state = minecraft.theWorld.getBlockState(phantom.getBoundPosition());
Block block = state.getBlock();
Item item = Item.getItemFromBlock(block);
String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(block, 1, block.getMetaFromState(state)));
StringUtil.drawSplitString(minecraft.fontRendererObj, StringUtil.localizeFormatted("tooltip."+ModUtil.MOD_ID+".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.fontRendererObj, EnumChatFormatting.DARK_GREEN+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
StringUtil.drawSplitString(minecraft.fontRendererObj, TextFormatting.DARK_GREEN+StringUtil.localize("tooltip."+ModUtil.MOD_ID+".phantom.connectedRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
}
else{
StringUtil.drawSplitString(minecraft.fontRendererObj, EnumChatFormatting.DARK_RED+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
StringUtil.drawSplitString(minecraft.fontRendererObj, TextFormatting.DARK_RED+StringUtil.localize("tooltip."+ModUtil.MOD_ID+".phantom.connectedNoRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
}
}
else{
minecraft.fontRendererObj.drawStringWithShadow(EnumChatFormatting.RED+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.RED+StringUtil.localize("tooltip."+ModUtil.MOD_ID+".phantom.notConnected.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, StringUtil.DECIMAL_COLOR_WHITE);
}
}
}
@ -129,6 +160,7 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
PLACER,
BREAKER,
LIQUIFACE,
ENERGYFACE
ENERGYFACE,
REDSTONEFACE
}
}

View file

@ -1,43 +1,52 @@
/*
* This file ("BlockPhantomBooster.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockPhantomBooster.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomBooster;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
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);
public BlockPhantomBooster(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
float f = 1F/16F;
this.setBlockBounds(2*f, 0F, 2*f, 1-2*f, 1F, 1-2*f);
this.setSoundType(SoundType.STONE);
}
@Override
public boolean isFullCube(){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
return AABB;
}
@Override
public boolean isFullCube(IBlockState state){
return false;
}
@Override
public boolean isOpaqueCube(){
public boolean isOpaqueCube(IBlockState state){
return false;
}
@ -46,6 +55,7 @@ public class BlockPhantomBooster extends BlockContainerBase{
return EnumRarity.EPIC;
}
@Override
public TileEntity createNewTileEntity(World world, int i){
return new TileEntityPhantomBooster();

View file

@ -0,0 +1,58 @@
/*
* This file ("BlockPlayerInterface.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockPlayerInterface extends BlockContainerBase{
public BlockPlayerInterface(String name){
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(4.5F);
this.setResistance(10.0F);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityPlayerInterface();
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.EPIC;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
TileEntity tile = world.getTileEntity(pos);
if(tile != null && tile instanceof TileEntityPlayerInterface){
TileEntityPlayerInterface face = (TileEntityPlayerInterface)tile;
if(face.connectedPlayer == null){
face.connectedPlayer = player.getUniqueID();
face.markDirty();
}
}
super.onBlockPlacedBy(world, pos, state, player, stack);
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockRangedCollector.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockRangedCollector.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -14,33 +14,36 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockRangedCollector extends BlockContainerBase{
public BlockRangedCollector(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityRangedCollector();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityRangedCollector breaker = (TileEntityRangedCollector)world.getTileEntity(pos);
if(breaker != null){

View file

@ -0,0 +1,108 @@
/*
* This file ("BlockShockSuppressor.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityShockSuppressor;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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 BlockShockSuppressor(String name){
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(20.0F);
this.setResistance(2000.0F);
this.setSoundType(SoundType.STONE);
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onExplosion(ExplosionEvent.Detonate event){
World world = event.getWorld();
if(!world.isRemote){
List<BlockPos> affectedBlocks = event.getAffectedBlocks();
List<Entity> affectedEntities = event.getAffectedEntities();
int rangeSq = TileEntityShockSuppressor.RANGE*TileEntityShockSuppressor.RANGE;
int use = TileEntityShockSuppressor.USE_PER;
for(TileEntityShockSuppressor suppressor : TileEntityShockSuppressor.SUPPRESSORS){
if(!suppressor.isRedstonePowered){
BlockPos supPos = suppressor.getPos();
List<Entity> entitiesToRemove = new ArrayList<Entity>();
List<BlockPos> posesToRemove = new ArrayList<BlockPos>();
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){
entitiesToRemove.add(entity);
}
}
Collections.shuffle(entitiesToRemove);
Collections.shuffle(posesToRemove);
for(BlockPos pos : posesToRemove){
if(suppressor.storage.getEnergyStored() >= use){
suppressor.storage.extractEnergy(use, false);
affectedBlocks.remove(pos);
}
else{
break;
}
}
for(Entity entity : entitiesToRemove){
if(suppressor.storage.getEnergyStored() >= use){
suppressor.storage.extractEnergy(use, false);
affectedEntities.remove(entity);
}
else{
break;
}
}
}
}
}
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.RARE;
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta){
return new TileEntityShockSuppressor();
}
}

View file

@ -1,74 +1,63 @@
/*
* This file ("BlockSlabs.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockSlabs.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.List;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockSlabs extends BlockBase{
private 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 static final PropertyInteger META = PropertyInteger.create("meta", 0, 1);
private Block fullBlock;
private int meta;
private final Block fullBlock;
private final int meta;
public BlockSlabs(String name, Block fullBlock){
this(name, fullBlock, 0);
}
public BlockSlabs(String name, Block fullBlock, int meta){
super(fullBlock.getMaterial(), name);
super(fullBlock.getMaterial(fullBlock.getDefaultState()), name);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.fullBlock = fullBlock;
this.meta = meta;
}
@Override
/*@Override
public void addCollisionBoxesToList(World world, BlockPos pos, IBlockState state, AxisAlignedBB axis, List list, Entity entity){
this.setBlockBoundsBasedOnState(world, pos);
super.addCollisionBoxesToList(world, pos, state, axis, list, entity);
}
@Override
public boolean isOpaqueCube(){
return false;
}
@Override
public IBlockState onBlockPlaced(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 void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos){
int meta = PosUtil.getMetadata(pos, world);
@ -80,11 +69,33 @@ public class BlockSlabs extends BlockBase{
@Override
public void setBlockBoundsForItemRender(){
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}*/
@Override
public boolean isOpaqueCube(IBlockState state){
return false;
}
@Override
public IBlockState onBlockPlaced(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 Class<? extends ItemBlockBase> getItemBlock(){
return TheItemBlock.class;
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
return state.getValue(META) == 1 ? AABB_TOP_HALF : AABB_BOTTOM_HALF;
}
@Override
protected ItemBlockBase getItemBlock(){
return new TheItemBlock(this);
}
@Override
@ -106,17 +117,68 @@ public class BlockSlabs extends BlockBase{
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ){
if(PosUtil.getBlock(pos, world) == this.block && ((side.ordinal() == 1 && PosUtil.getMetadata(pos, world) == 0) || (side.ordinal() == 0 && PosUtil.getMetadata(pos, world) == 1))){
if(PosUtil.setBlock(pos, world, ((BlockSlabs)this.block).fullBlock, ((BlockSlabs)this.block).meta, 3)){
world.playSoundEffect(pos.getX()+0.5F, pos.getY()+0.5F, pos.getZ()+0.5F, this.block.stepSound.getBreakSound(), (this.block.stepSound.getVolume()+1.0F)/2.0F, this.block.stepSound.frequency*0.8F);
stack.stackSize--;
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
if(stack.stackSize != 0 && playerIn.canPlayerEdit(pos.offset(facing), facing, stack)){
IBlockState state = worldIn.getBlockState(pos);
if(state.getBlock() == this.block){
BlockSlabs theBlock = (BlockSlabs)this.block;
if((facing == EnumFacing.UP && state.getValue(META) == 0 || facing == EnumFacing.DOWN && state.getValue(META) == 1)){
IBlockState newState = theBlock.fullBlock.getStateFromMeta(theBlock.meta);
AxisAlignedBB bound = newState.getCollisionBoundingBox(worldIn, pos);
if(bound != Block.NULL_AABB && worldIn.checkNoEntityCollision(bound.offset(pos)) && worldIn.setBlockState(pos, newState, 11)){
SoundType soundtype = theBlock.fullBlock.getSoundType();
worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
--stack.stackSize;
}
return EnumActionResult.SUCCESS;
}
}
return this.tryPlace(playerIn, stack, worldIn, pos.offset(facing)) ? EnumActionResult.SUCCESS : super.onItemUse(stack, playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
else{
return EnumActionResult.FAIL;
}
}
@Override
@SideOnly(Side.CLIENT)
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(META) == 0 || side == EnumFacing.DOWN && state.getValue(META) == 1)){
return true;
}
}
return super.onItemUse(stack, player, world, pos, side, hitX, hitY, hitZ);
return worldIn.getBlockState(pos.offset(side)).getBlock() == this.block || super.canPlaceBlockOnSide(worldIn, pos, side, player, stack);
}
private boolean tryPlace(EntityPlayer player, ItemStack stack, World worldIn, BlockPos pos){
IBlockState iblockstate = worldIn.getBlockState(pos);
if(iblockstate.getBlock() == this.block){
BlockSlabs theBlock = (BlockSlabs)this.block;
IBlockState newState = theBlock.fullBlock.getStateFromMeta(theBlock.meta);
AxisAlignedBB bound = newState.getCollisionBoundingBox(worldIn, pos);
if(bound != Block.NULL_AABB && worldIn.checkNoEntityCollision(bound.offset(pos)) && worldIn.setBlockState(pos, newState, 11)){
SoundType soundtype = theBlock.fullBlock.getSoundType();
worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
--stack.stackSize;
}
return true;
}
return false;
}
@Override
public String getUnlocalizedName(ItemStack stack){
return this.getUnlocalizedName();

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockSmileyCloud.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockSmileyCloud.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -16,57 +16,52 @@ import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
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.world.IBlockAccess;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
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 BlockSmileyCloud extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 3);
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 7);
public BlockSmileyCloud(String name){
super(Material.cloth, name);
super(Material.CLOTH, name);
this.setHardness(0.5F);
this.setResistance(5.0F);
this.setStepSound(soundTypeCloth);
this.setSoundType(SoundType.CLOTH);
this.setTickRandomly(true);
}
@Override
public boolean isFullCube(){
public boolean isFullCube(IBlockState state){
return false;
}
@Override
public void addCollisionBoxesToList(World world, BlockPos pos, IBlockState state, AxisAlignedBB axis, List list, Entity entity){
this.setBlockBoundsBasedOnState(world, pos);
super.addCollisionBoxesToList(world, pos, state, axis, list, entity);
}
@Override
public boolean isOpaqueCube(){
public boolean isOpaqueCube(IBlockState state){
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){
if(Util.RANDOM.nextInt(30) == 0){
for(int i = 0; i < 2; i++){
double d = Util.RANDOM.nextGaussian()*0.02D;
@ -78,36 +73,18 @@ public class BlockSmileyCloud extends BlockContainerBase{
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing f6, float f7, float f8, float f9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing f6, float f7, float f8, float f9){
if(!world.isRemote){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntitySmileyCloud){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.CLOUD.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
player.triggerAchievement(TheAchievements.NAME_SMILEY_CLOUD.ach);
player.addStat(TheAchievements.NAME_SMILEY_CLOUD.chieve);
}
}
return true;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos){
int meta = PosUtil.getMetadata(pos, world);
float f = 0.0625F;
if(meta == 1){
this.setBlockBounds(0F, 0F, 0F, 1F, 1F-f*3F, 1F-f*2F);
}
if(meta == 3){
this.setBlockBounds(0F, 0F, 0F, 1F-f*2F, 1F-f*3F, 1F);
}
if(meta == 0){
this.setBlockBounds(0F, 0F, f*2F, 1F, 1F-f*3F, 1F);
}
if(meta == 2){
this.setBlockBounds(f*2F, 0F, 0F, 1F, 1F-f*3F, 1F);
}
}
@Override
public TileEntity createNewTileEntity(World world, int meta){
@ -130,16 +107,16 @@ public class BlockSmileyCloud extends BlockContainerBase{
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
if(rotation == 0){
PosUtil.setMetadata(pos, world, 0, 2);
world.setBlockState(pos, this.getStateFromMeta(0), 2);
}
if(rotation == 1){
PosUtil.setMetadata(pos, world, 3, 2);
world.setBlockState(pos, this.getStateFromMeta(3), 2);
}
if(rotation == 2){
PosUtil.setMetadata(pos, world, 1, 2);
world.setBlockState(pos, this.getStateFromMeta(1), 2);
}
if(rotation == 3){
PosUtil.setMetadata(pos, world, 2, 2);
world.setBlockState(pos, this.getStateFromMeta(2), 2);
}
super.onBlockPlacedBy(world, pos, state, player, stack);

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockTreasureChest.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockTreasureChest.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -14,19 +14,21 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot;
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -38,17 +40,17 @@ public class BlockTreasureChest extends BlockBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 3);
public BlockTreasureChest(String name){
super(Material.wood, name);
super(Material.WOOD, name);
this.setHarvestLevel("axe", 0);
this.setHardness(300.0F);
this.setResistance(50.0F);
this.setStepSound(soundTypeWood);
this.setSoundType(SoundType.WOOD);
this.setTickRandomly(true);
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
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();
@ -64,13 +66,13 @@ public class BlockTreasureChest extends BlockBase{
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
world.playSoundAtEntity(player, "random.chestopen", 0.2F, Util.RANDOM.nextFloat()*0.1F+0.9F);
world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.2F, Util.RANDOM.nextFloat()*0.1F+0.9F);
this.dropItems(world, pos);
world.setBlockToAir(pos);
player.triggerAchievement(TheAchievements.OPEN_TREASURE_CHEST.ach);
player.addStat(TheAchievements.OPEN_TREASURE_CHEST.chieve);
}
return true;
}
@ -80,16 +82,16 @@ public class BlockTreasureChest extends BlockBase{
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
if(rotation == 0){
PosUtil.setMetadata(pos, world, 0, 2);
world.setBlockState(pos, this.getStateFromMeta(0), 2);
}
if(rotation == 1){
PosUtil.setMetadata(pos, world, 3, 2);
world.setBlockState(pos, this.getStateFromMeta(3), 2);
}
if(rotation == 2){
PosUtil.setMetadata(pos, world, 1, 2);
world.setBlockState(pos, this.getStateFromMeta(1), 2);
}
if(rotation == 3){
PosUtil.setMetadata(pos, world, 2, 2);
world.setBlockState(pos, this.getStateFromMeta(2), 2);
}
}
@ -100,7 +102,7 @@ public class BlockTreasureChest extends BlockBase{
private void dropItems(World world, BlockPos pos){
for(int i = 0; i < MathHelper.getRandomIntegerInRange(Util.RANDOM, 3, 6); i++){
TreasureChestLoot theReturn = WeightedRandom.getRandomItem(Util.RANDOM, ActuallyAdditionsAPI.treasureChestLoot);
TreasureChestLoot theReturn = WeightedRandom.getRandomItem(Util.RANDOM, ActuallyAdditionsAPI.TREASURE_CHEST_LOOT);
ItemStack itemStack = theReturn.returnItem.copy();
itemStack.stackSize = MathHelper.getRandomIntegerInRange(Util.RANDOM, theReturn.minAmount, theReturn.maxAmount);
@ -108,9 +110,6 @@ public class BlockTreasureChest extends BlockBase{
float dY = Util.RANDOM.nextFloat()*0.8F+0.1F;
float dZ = Util.RANDOM.nextFloat()*0.8F+0.1F;
EntityItem entityItem = new EntityItem(world, pos.getX()+dX, pos.getY()+dY, pos.getZ()+dZ, itemStack.copy());
if(itemStack.hasTagCompound()){
entityItem.getEntityItem().setTagCompound((NBTTagCompound)itemStack.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = Util.RANDOM.nextGaussian()*factor;
entityItem.motionY = Util.RANDOM.nextGaussian()*factor+0.2F;

View file

@ -0,0 +1,155 @@
/*
* This file ("BlockWallAA.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFenceGate;
import net.minecraft.block.BlockWall;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
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)};
private final int meta;
public BlockWallAA(String name, Block base){
this(name, base, 0);
}
public BlockWallAA(String name, Block base, int meta){
super(base.getMaterial(base.getDefaultState()), name);
this.meta = meta;
this.setHardness(1.5F);
this.setResistance(10F);
this.setSoundType(base.getSoundType());
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){
int i = 0;
if(state.getValue(BlockWall.NORTH)){
i |= 1 << EnumFacing.NORTH.getHorizontalIndex();
}
if(state.getValue(BlockWall.EAST)){
i |= 1 << EnumFacing.EAST.getHorizontalIndex();
}
if(state.getValue(BlockWall.SOUTH)){
i |= 1 << EnumFacing.SOUTH.getHorizontalIndex();
}
if(state.getValue(BlockWall.WEST)){
i |= 1 << EnumFacing.WEST.getHorizontalIndex();
}
return i;
}
@Override
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());
boolean flag3 = this.canConnectTo(worldIn, pos.west());
boolean flag4 = flag && !flag1 && flag2 && !flag3 || !flag && flag1 && !flag2 && flag3;
return state.withProperty(BlockWall.UP, !flag4 || !worldIn.isAirBlock(pos.up())).withProperty(BlockWall.NORTH, flag).withProperty(BlockWall.EAST, flag1).withProperty(BlockWall.SOUTH, flag2).withProperty(BlockWall.WEST, flag3);
}
@Override
public boolean isFullCube(IBlockState state){
return false;
}
@Override
public boolean isPassable(IBlockAccess worldIn, BlockPos pos){
return false;
}
@Override
@SideOnly(Side.CLIENT)
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){
state = this.getActualState(state, source, pos);
return AABB_BY_INDEX[yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(state)];
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos){
blockState = this.getActualState(blockState, worldIn, pos);
return CLIP_AABB_BY_INDEX[yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(blockState)];
}
@Override
public boolean isOpaqueCube(IBlockState state){
return false;
}
@Override
public int damageDropped(IBlockState state){
return this.meta;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list){
list.add(new ItemStack(item, 1, 0));
}
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)) || ((block.getMaterial(state).isOpaque() && block.isFullCube(state)) && block.getMaterial(state) != Material.GOURD));
}
@Override
public IBlockState getStateFromMeta(int meta){
return this.getDefaultState();
}
@Override
public int getMetaFromState(IBlockState state){
return 0;
}
@Override
protected BlockStateContainer createBlockState(){
return new BlockStateContainer(this, BlockWall.UP, BlockWall.NORTH, BlockWall.EAST, BlockWall.WEST, BlockWall.SOUTH);
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockWildPlant.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockWildPlant.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -16,10 +16,9 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBushBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheWildPlants;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
@ -28,9 +27,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
@ -40,39 +39,42 @@ import java.util.List;
public class BlockWildPlant extends BlockBushBase{
public static final TheWildPlants[] allWildPlants = TheWildPlants.values();
private static final PropertyInteger META = PropertyInteger.create("meta", 0, allWildPlants.length-1);
public static final TheWildPlants[] ALL_WILD_PLANTS = TheWildPlants.values();
private static final PropertyInteger META = PropertyInteger.create("meta", 0, ALL_WILD_PLANTS.length-1);
public BlockWildPlant(String name){
super(name);
this.setStepSound(soundTypeGrass);
this.setSoundType(SoundType.PLANT);
}
@Override
public boolean canBlockStay(World world, BlockPos pos, IBlockState state){
BlockPos offset = PosUtil.offset(pos, 0, -1, 0);
return PosUtil.getMetadata(pos, world) == TheWildPlants.RICE.ordinal() ? PosUtil.getMaterial(offset, world) == Material.water : PosUtil.getBlock(offset, world).canSustainPlant(world, offset, EnumFacing.UP, this);
BlockPos offset = pos.down();
IBlockState offsetState = world.getBlockState(offset);
Block offsetBlock = offsetState.getBlock();
return offsetBlock.getMetaFromState(offsetState) == TheWildPlants.RICE.ordinal() ? offsetBlock.getMaterial(offsetState) == Material.WATER : offsetBlock.canSustainPlant(world.getBlockState(offset), world, offset, EnumFacing.UP, this);
}
@Override
@SideOnly(Side.CLIENT)
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player){
int metadata = this.getMetaFromState(state);
return metadata >= ALL_WILD_PLANTS.length ? null : new ItemStack(((BlockPlant)ALL_WILD_PLANTS[metadata].wildVersionOf).seedItem);
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem(World world, BlockPos pos){
int metadata = PosUtil.getMetadata(pos, world);
return metadata >= allWildPlants.length ? null : ((BlockPlant)allWildPlants[metadata].wildVersionOf).seedItem;
}
@SuppressWarnings("all")
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list){
for(int j = 0; j < allWildPlants.length; j++){
for(int j = 0; j < ALL_WILD_PLANTS.length; j++){
list.add(new ItemStack(item, 1, j));
}
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune){
int metadata = state.getBlock().getMetaFromState(state);
return metadata >= allWildPlants.length ? null : allWildPlants[metadata].wildVersionOf.getDrops(world, pos, allWildPlants[metadata].wildVersionOf.getStateFromMeta(7), fortune);
int metadata = this.getMetaFromState(state);
return metadata >= ALL_WILD_PLANTS.length ? null : ALL_WILD_PLANTS[metadata].wildVersionOf.getDrops(world, pos, ALL_WILD_PLANTS[metadata].wildVersionOf.getStateFromMeta(7), fortune);
}
@Override
@ -81,8 +83,8 @@ public class BlockWildPlant extends BlockBushBase{
}
@Override
public Class<? extends ItemBlockBase> getItemBlock(){
return TheItemBlock.class;
protected ItemBlockBase getItemBlock(){
return new TheItemBlock(this);
}
@Override
@ -92,18 +94,14 @@ public class BlockWildPlant extends BlockBushBase{
@Override
protected void registerRendering(){
ResourceLocation[] resLocs = new ResourceLocation[allWildPlants.length];
for(int i = 0; i < allWildPlants.length; i++){
String name = this.getBaseName()+allWildPlants[i].name;
resLocs[i] = new ResourceLocation(ModUtil.MOD_ID_LOWER, name);
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(ModUtil.MOD_ID_LOWER, name));
for(int i = 0; i < ALL_WILD_PLANTS.length; i++){
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), META.getName()+"="+i);
}
ActuallyAdditions.proxy.addRenderVariant(Item.getItemFromBlock(this), resLocs);
}
@Override
public EnumRarity getRarity(ItemStack stack){
return stack.getItemDamage() >= allWildPlants.length ? EnumRarity.COMMON : allWildPlants[stack.getItemDamage()].rarity;
return stack.getItemDamage() >= ALL_WILD_PLANTS.length ? EnumRarity.COMMON : ALL_WILD_PLANTS[stack.getItemDamage()].rarity;
}
@Override
@ -119,9 +117,10 @@ public class BlockWildPlant extends BlockBushBase{
this.setMaxDamage(0);
}
@Override
public String getUnlocalizedName(ItemStack stack){
return stack.getItemDamage() >= allWildPlants.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+allWildPlants[stack.getItemDamage()].name;
return stack.getItemDamage() >= ALL_WILD_PLANTS.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+ALL_WILD_PLANTS[stack.getItemDamage()].name;
}
}
}

View file

@ -1,11 +1,11 @@
/*
* This file ("BlockXPSolidifier.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockXPSolidifier.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -16,8 +16,8 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState;
@ -27,9 +27,10 @@ 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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
public class BlockXPSolidifier extends BlockContainerBase{
@ -37,20 +38,21 @@ public class BlockXPSolidifier extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 3);
public BlockXPSolidifier(String name){
super(Material.rock, name);
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(2.5F);
this.setResistance(10.0F);
this.setStepSound(soundTypeStone);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World world, int par2){
return new TileEntityXPSolidifier();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityXPSolidifier solidifier = (TileEntityXPSolidifier)world.getTileEntity(pos);
if(solidifier != null){
@ -71,16 +73,16 @@ public class BlockXPSolidifier extends BlockContainerBase{
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
if(rotation == 0){
PosUtil.setMetadata(pos, world, 0, 2);
world.setBlockState(pos, this.getStateFromMeta(0), 2);
}
if(rotation == 1){
PosUtil.setMetadata(pos, world, 3, 2);
world.setBlockState(pos, this.getStateFromMeta(3), 2);
}
if(rotation == 2){
PosUtil.setMetadata(pos, world, 1, 2);
world.setBlockState(pos, this.getStateFromMeta(1), 2);
}
if(rotation == 3){
PosUtil.setMetadata(pos, world, 2, 2);
world.setBlockState(pos, this.getStateFromMeta(2), 2);
}
super.onBlockPlacedBy(world, pos, state, player, stack);

View file

@ -1,11 +1,11 @@
/*
* This file ("IHudDisplay.java") is part of the Actually Additions Mod for Minecraft.
* This file ("IHudDisplay.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
@ -15,13 +15,13 @@ import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public interface IHudDisplay{
@SideOnly(Side.CLIENT)
void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution);
void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, Profiler profiler, ScaledResolution resolution);
}

View file

@ -1,30 +1,31 @@
/*
* This file ("InitBlocks.java") is part of the Actually Additions Mod for Minecraft.
* This file ("InitBlocks.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockStair;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockWallAA;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
import de.ellpeck.actuallyadditions.mod.util.CompatUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil;
import net.minecraft.block.Block;
public class InitBlocks{
public final class InitBlocks{
public static Block blockCompost;
public static Block blockMisc;
public static Block blockWildPlant;
public static Block blockFeeder;
public static Block blockGiantChest;
public static Block blockGiantChestMedium;
public static Block blockGiantChestLarge;
public static Block blockGrinder;
public static Block blockGrinderDouble;
@ -57,6 +58,8 @@ public class InitBlocks{
public static Block blockPhantomBreaker;
public static Block blockPhantomLiquiface;
public static Block blockPhantomEnergyface;
public static Block blockPhantomRedstoneface;
public static Block blockPlayerInterface;
public static Block blockFluidPlacer;
public static Block blockFluidCollector;
@ -92,6 +95,9 @@ public class InitBlocks{
public static Block blockRangedCollector;
public static Block blockLaserRelay;
public static Block blockLaserRelayItem;
public static Block blockLaserRelayItemWhitelist;
public static Block blockItemViewer;
public static Block blockBlackLotus;
public static Block blockCrystal;
@ -111,15 +117,26 @@ public class InitBlocks{
public static Block blockPillarQuartzStair;
public static Block blockPillarQuartzSlab;
public static Block blockBookletStand;
public static Block blockDisplayStand;
public static Block blockShockSuppressor;
public static void init(){
ModUtil.LOGGER.info("Initializing Blocks...");
blockShockSuppressor = new BlockShockSuppressor("blockShockSuppressor");
blockDisplayStand = new BlockDisplayStand("blockDisplayStand");
blockPlayerInterface = new BlockPlayerInterface("blockPlayerInterface");
blockBookletStand = new BlockBookletStand("blockBookletStand");
blockItemViewer = new BlockItemViewer("blockItemViewer");
blockFireworkBox = new BlockFireworkBox("blockFireworkBox");
blockMiner = new BlockMiner("blockMiner");
blockAtomicReconstructor = new BlockAtomicReconstructor("blockAtomicReconstructor");
blockCrystal = new BlockCrystal("blockCrystal");
blockBlackLotus = new BlockBlackLotus("blockBlackLotus");
blockLaserRelay = new BlockLaserRelay("blockLaserRelay");
blockLaserRelay = new BlockLaserRelay("blockLaserRelay", BlockLaserRelay.Type.ENERGY);
blockLaserRelayItem = new BlockLaserRelay("blockLaserRelayItem", BlockLaserRelay.Type.ITEM);
blockLaserRelayItemWhitelist = new BlockLaserRelay("blockLaserRelayItemWhitelist", BlockLaserRelay.Type.ITEM_WHITELIST);
blockRangedCollector = new BlockRangedCollector("blockRangedCollector");
blockDirectionalBreaker = new BlockDirectionalBreaker("blockDirectionalBreaker");
blockLeafGenerator = new BlockLeafGenerator("blockLeafGenerator");
@ -145,6 +162,7 @@ public class InitBlocks{
blockPhantomPlacer = new BlockPhantom(BlockPhantom.Type.PLACER, "blockPhantomPlacer");
blockPhantomLiquiface = new BlockPhantom(BlockPhantom.Type.LIQUIFACE, "blockPhantomLiquiface");
blockPhantomEnergyface = new BlockPhantom(BlockPhantom.Type.ENERGYFACE, "blockPhantomEnergyface");
blockPhantomRedstoneface = new BlockPhantom(BlockPhantom.Type.REDSTONEFACE, "blockPhantomRedstoneface");
blockPhantomBreaker = new BlockPhantom(BlockPhantom.Type.BREAKER, "blockPhantomBreaker");
blockCoalGenerator = new BlockCoalGenerator("blockCoalGenerator");
blockOilGenerator = new BlockOilGenerator("blockOilGenerator");
@ -160,7 +178,9 @@ public class InitBlocks{
blockCompost = new BlockCompost("blockCompost");
blockMisc = new BlockMisc("blockMisc");
blockFeeder = new BlockFeeder("blockFeeder");
blockGiantChest = new BlockGiantChest("blockGiantChest");
blockGiantChest = new BlockGiantChest("blockGiantChest", 0);
blockGiantChestMedium = new BlockGiantChest("blockGiantChestMedium", 1);
blockGiantChestLarge = new BlockGiantChest("blockGiantChestLarge", 2);
blockGrinder = new BlockGrinder(false, "blockGrinder");
blockGrinderDouble = new BlockGrinder(true, "blockGrinderDouble");
blockFurnaceDouble = new BlockFurnaceDouble("blockFurnaceDouble");

View file

@ -1,31 +1,28 @@
/*
* This file ("BlockBase.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockBase.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks.base;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class BlockBase extends Block{
public class BlockBase extends Block implements ItemBlockBase.ICustomRarity{
private String name;
private final String name;
public BlockBase(Material material, String name){
super(material);
@ -35,14 +32,7 @@ public class BlockBase extends Block{
}
private void register(){
this.setUnlocalizedName(ModUtil.MOD_ID_LOWER+"."+this.getBaseName());
GameRegistry.registerBlock(this, this.getItemBlock(), this.getBaseName());
if(this.shouldAddCreative()){
this.setCreativeTab(CreativeTab.instance);
}
else{
this.setCreativeTab(null);
}
ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
this.registerRendering();
}
@ -51,8 +41,8 @@ public class BlockBase extends Block{
return this.name;
}
protected Class<? extends ItemBlockBase> getItemBlock(){
return ItemBlockBase.class;
protected ItemBlockBase getItemBlock(){
return new ItemBlockBase(this);
}
public boolean shouldAddCreative(){
@ -60,9 +50,10 @@ public class BlockBase extends Block{
}
protected void registerRendering(){
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), new ResourceLocation(ModUtil.MOD_ID_LOWER, this.getBaseName()));
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.COMMON;
}
@ -77,9 +68,10 @@ public class BlockBase extends Block{
return this.getMetaProperty() == null ? super.getMetaFromState(state) : state.getValue(this.getMetaProperty());
}
@Override
protected BlockState createBlockState(){
return this.getMetaProperty() == null ? super.createBlockState() : new BlockState(this, this.getMetaProperty());
protected BlockStateContainer createBlockState(){
return this.getMetaProperty() == null ? super.createBlockState() : new BlockStateContainer(this, this.getMetaProperty());
}
protected PropertyInteger getMetaProperty(){

View file

@ -1,47 +1,38 @@
/*
* This file ("BlockBushBase.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockBushBase.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks.base;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import net.minecraft.block.BlockBush;
import net.minecraft.block.SoundType;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class BlockBushBase extends BlockBush{
public class BlockBushBase extends BlockBush implements ItemBlockBase.ICustomRarity{
private String name;
private final String name;
public BlockBushBase(String name){
this.name = name;
this.setStepSound(soundTypeGrass);
this.setSoundType(SoundType.PLANT);
this.register();
}
private void register(){
this.setUnlocalizedName(ModUtil.MOD_ID_LOWER+"."+this.getBaseName());
GameRegistry.registerBlock(this, this.getItemBlock(), this.getBaseName());
if(this.shouldAddCreative()){
this.setCreativeTab(CreativeTab.instance);
}
else{
this.setCreativeTab(null);
}
ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
this.registerRendering();
}
@ -50,8 +41,8 @@ public class BlockBushBase extends BlockBush{
return this.name;
}
protected Class<? extends ItemBlockBase> getItemBlock(){
return ItemBlockBase.class;
protected ItemBlockBase getItemBlock(){
return new ItemBlockBase(this);
}
public boolean shouldAddCreative(){
@ -59,9 +50,10 @@ public class BlockBushBase extends BlockBush{
}
protected void registerRendering(){
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), new ResourceLocation(ModUtil.MOD_ID_LOWER, this.getBaseName()));
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.COMMON;
}
@ -76,9 +68,10 @@ public class BlockBushBase extends BlockBush{
return this.getMetaProperty() == null ? super.getMetaFromState(state) : state.getValue(this.getMetaProperty());
}
@Override
protected BlockState createBlockState(){
return this.getMetaProperty() == null ? super.createBlockState() : new BlockState(this, this.getMetaProperty());
protected BlockStateContainer createBlockState(){
return this.getMetaProperty() == null ? super.createBlockState() : new BlockStateContainer(this, this.getMetaProperty());
}
protected PropertyInteger getMetaProperty(){

View file

@ -1,26 +1,26 @@
/*
* This file ("BlockContainerBase.java") is part of the Actually Additions Mod for Minecraft.
* This file ("BlockContainerBase.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense/
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2016 Ellpeck
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks.base;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
import de.ellpeck.actuallyadditions.mod.tile.*;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockRedstoneTorch;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
@ -29,21 +29,24 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public abstract class BlockContainerBase extends BlockContainer{
public abstract class BlockContainerBase extends BlockContainer implements ItemBlockBase.ICustomRarity{
private String name;
private final String name;
public BlockContainerBase(Material material, String name){
super(material);
@ -53,14 +56,7 @@ public abstract class BlockContainerBase extends BlockContainer{
}
private void register(){
this.setUnlocalizedName(ModUtil.MOD_ID_LOWER+"."+this.getBaseName());
GameRegistry.registerBlock(this, this.getItemBlock(), this.getBaseName());
if(this.shouldAddCreative()){
this.setCreativeTab(CreativeTab.instance);
}
else{
this.setCreativeTab(null);
}
ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
this.registerRendering();
}
@ -69,8 +65,8 @@ public abstract class BlockContainerBase extends BlockContainer{
return this.name;
}
protected Class<? extends ItemBlockBase> getItemBlock(){
return ItemBlockBase.class;
protected ItemBlockBase getItemBlock(){
return new ItemBlockBase(this);
}
public boolean shouldAddCreative(){
@ -78,9 +74,10 @@ public abstract class BlockContainerBase extends BlockContainer{
}
protected void registerRendering(){
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), new ResourceLocation(ModUtil.MOD_ID_LOWER, this.getBaseName()));
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.COMMON;
}
@ -106,9 +103,6 @@ public abstract class BlockContainerBase extends BlockContainer{
float dY = Util.RANDOM.nextFloat()*0.8F+0.1F;
float dZ = Util.RANDOM.nextFloat()*0.8F+0.1F;
EntityItem entityItem = new EntityItem(world, pos.getX()+dX, pos.getY()+dY, pos.getZ()+dZ, stack.copy());
if(stack.hasTagCompound()){
entityItem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = Util.RANDOM.nextGaussian()*factor;
entityItem.motionY = Util.RANDOM.nextGaussian()*factor+0.2F;
@ -118,12 +112,13 @@ public abstract class BlockContainerBase extends BlockContainer{
}
public boolean tryToggleRedstone(World world, BlockPos pos, EntityPlayer player){
ItemStack stack = player.getCurrentEquippedItem();
ItemStack stack = player.getHeldItemMainhand();
if(stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof IRedstoneToggle){
if(!world.isRemote){
((IRedstoneToggle)tile).toggle(!((IRedstoneToggle)tile).isPulseMode());
if(tile instanceof TileEntityBase){
TileEntityBase base = (TileEntityBase)tile;
if(!world.isRemote && base.isRedstoneToggle()){
base.isPulseMode = !base.isPulseMode;
tile.markDirty();
if(tile instanceof TileEntityBase){
@ -150,36 +145,44 @@ public abstract class BlockContainerBase extends BlockContainer{
public void updateTick(World world, BlockPos pos, IBlockState state, Random random){
if(!world.isRemote){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof IRedstoneToggle && ((IRedstoneToggle)tile).isPulseMode()){
((IRedstoneToggle)tile).activateOnPulse();
if(tile instanceof TileEntityBase){
TileEntityBase base = (TileEntityBase)tile;
if(base.isRedstoneToggle() && base.isPulseMode){
base.activateOnPulse();
}
}
}
}
@Override
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock){
this.updateRedstoneState(world, pos);
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn){
this.updateRedstoneState(worldIn, pos);
}
public void updateRedstoneState(World world, BlockPos pos){
if(!world.isRemote){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityBase){
TileEntityBase base = (TileEntityBase)tile;
boolean powered = world.isBlockIndirectlyGettingPowered(pos) > 0;
boolean wasPowered = ((TileEntityBase)tile).isRedstonePowered;
boolean wasPowered = base.isRedstonePowered;
if(powered && !wasPowered){
if(tile instanceof IRedstoneToggle && ((IRedstoneToggle)tile).isPulseMode()){
if(base.isRedstoneToggle() && base.isPulseMode){
world.scheduleUpdate(pos, this, this.tickRate(world));
}
((TileEntityBase)tile).setRedstonePowered(true);
base.setRedstonePowered(true);
}
else if(!powered && wasPowered){
((TileEntityBase)tile).setRedstonePowered(false);
base.setRedstonePowered(false);
}
}
}
}
protected boolean checkFailUseItemOnTank(EntityPlayer player, ItemStack heldItem, FluidTank tank){
return heldItem == null || !FluidUtil.interactWithFluidHandler(heldItem, tank, player);
}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state){
this.updateRedstoneState(world, pos);
@ -187,31 +190,12 @@ public abstract class BlockContainerBase extends BlockContainer{
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack){
if(stack.getTagCompound() != null){
if(stack.hasTagCompound()){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof IEnergySaver){
((IEnergySaver)tile).setEnergy(stack.getTagCompound().getInteger("Energy"));
stack.getTagCompound().removeTag("Energy");
}
if(tile instanceof IFluidSaver){
int amount = stack.getTagCompound().getInteger("FluidAmount");
stack.getTagCompound().removeTag("FluidAmount");
if(amount > 0){
FluidStack[] fluids = new FluidStack[amount];
for(int i = 0; i < amount; i++){
NBTTagCompound compound = stack.getTagCompound().getCompoundTag("Fluid"+i);
stack.getTagCompound().removeTag("Fluid"+i);
if(compound != null){
fluids[i] = FluidStack.loadFluidStackFromNBT(compound);
}
}
((IFluidSaver)tile).setFluids(fluids);
}
if(tile instanceof TileEntityBase){
TileEntityBase base = (TileEntityBase)tile;
NBTTagCompound compound = stack.getTagCompound().getCompoundTag("Data");
base.readSyncableNBT(compound, TileEntityBase.NBTType.SAVE_BLOCK);
}
}
}
@ -220,16 +204,18 @@ public abstract class BlockContainerBase extends BlockContainer{
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player){
if(!player.capabilities.isCreativeMode){
this.dropBlockAsItem(world, pos, state, 0);
//dirty workaround because of Forge calling Item.onBlockStartBreak() twice
world.setBlockToAir(pos);
}
}
@Override
public boolean hasComparatorInputOverride(){
public boolean hasComparatorInputOverride(IBlockState state){
return true;
}
@Override
public int getComparatorInputOverride(World world, BlockPos pos){
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof IInventory){
return Container.calcRedstoneFromInventory((IInventory)tile);
@ -237,46 +223,43 @@ public abstract class BlockContainerBase extends BlockContainer{
return 0;
}
@Override
protected BlockState createBlockState(){
return this.getMetaProperty() == null ? super.createBlockState() : new BlockState(this, this.getMetaProperty());
protected BlockStateContainer createBlockState(){
return this.getMetaProperty() == null ? super.createBlockState() : new BlockStateContainer(this, this.getMetaProperty());
}
@Override
public ArrayList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune){
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
TileEntity tile = world.getTileEntity(pos);
if(tile != null){
ItemStack stack = new ItemStack(this.getItemDropped(state, Util.RANDOM, fortune), 1, this.damageDropped(state));
if(tile instanceof TileEntityBase){
TileEntityBase base = (TileEntityBase)tile;
NBTTagCompound data = new NBTTagCompound();
base.writeSyncableNBT(data, TileEntityBase.NBTType.SAVE_BLOCK);
if(tile instanceof IEnergySaver){
int energy = ((IEnergySaver)tile).getEnergy();
if(energy > 0){
if(stack.getTagCompound() == null){
stack.setTagCompound(new NBTTagCompound());
//Remove unnecessarily saved default values to avoid unstackability
List<String> keysToRemove = new ArrayList<String>();
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){
keysToRemove.add(key);
}
stack.getTagCompound().setInteger("Energy", energy);
}
}
for(String key : keysToRemove){
data.removeTag(key);
}
if(tile instanceof IFluidSaver){
FluidStack[] fluids = ((IFluidSaver)tile).getFluids();
if(fluids != null && fluids.length > 0){
if(stack.getTagCompound() == null){
stack.setTagCompound(new NBTTagCompound());
}
stack.getTagCompound().setInteger("FluidAmount", fluids.length);
for(int i = 0; i < fluids.length; i++){
if(fluids[i] != null && fluids[i].amount > 0){
NBTTagCompound compound = new NBTTagCompound();
fluids[i].writeToNBT(compound);
stack.getTagCompound().setTag("Fluid"+i, compound);
}
}
}
ItemStack stack = new ItemStack(this.getItemDropped(state, Util.RANDOM, fortune), 1, this.damageDropped(state));
if(!data.hasNoTags()){
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setTag("Data", data);
}
drops.add(stack);
@ -289,8 +272,9 @@ public abstract class BlockContainerBase extends BlockContainer{
return null;
}
@Override
public int getRenderType(){
return 3;
public EnumBlockRenderType getRenderType(IBlockState state){
return EnumBlockRenderType.MODEL;
}
}

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