chore: implement force bricks and massive refactors

This commit is contained in:
LordMZTE 2024-04-13 18:27:31 +02:00
parent b19d8f7349
commit 34dbac45e9
Signed by: LordMZTE
GPG Key ID: B64802DC33A64FF6
95 changed files with 3912 additions and 1610 deletions

129
.clang-format Normal file
View File

@ -0,0 +1,129 @@
---
AccessModifierOffset: 0
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: None
AlignConsecutiveAssignments: None
AlignConsecutiveMacros: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: DontAlign
AlignOperands: DontAlign
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros: []
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: After
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakAfterJavaFieldAnnotations: true
#BreakArrays: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakStringLiterals: true
ColumnLimit: 90
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: false # wtf
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros: ["BOOST_FOREACH"]
IfMacros: []
IncludeBlocks: Regroup
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: true
IndentPPDirectives: BeforeHash
#IndentRequiresClause: false
IndentWidth: 4
IndentWrappedFunctionNames: false
#InsertBraces: false
InsertTrailingCommas: Wrapped
JavaScriptQuotes: Double
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: OuterScope
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PackConstructorInitializers: NextLine
PointerAlignment: Left
QualifierAlignment: Left
ReferenceAlignment: Left
ReflowComments: true
#RemoveSemicolon: true
#RequiresClausePosition: OwnLine
#RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Always
SortIncludes: false
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: After
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: false
SpaceBeforeInheritanceColon: false
SpaceBeforeParens: ControlStatementsExceptControlMacros
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInLineCommentPrefix:
Minimum: 0
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++20
StatementAttributeLikeMacros: []
StatementMacros: []
TabWidth: 4
TypenameMacros: []
UseCRLF: false # wtf
UseTab: Never
WhitespaceSensitiveMacros: ["BOOST_PP_STRINGSIZE"]

View File

@ -24,6 +24,9 @@ version = "1.0"
group= "ley.modding.dartcraft"
archivesBaseName = "dartcraft"
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "run"

View File

@ -11,12 +11,13 @@ package buildcraft.api.tools;
import net.minecraft.entity.player.EntityPlayer;
/***
* Implement this interface on subclasses of Item to have that item work as a wrench for buildcraft
* Implement this interface on subclasses of Item to have that item work as a wrench for
* buildcraft
*/
public interface IToolWrench {
/***
* Called to ensure that the wrench can be used. To get the ItemStack that is used, check player.inventory.getCurrentItem()
* Called to ensure that the wrench can be used. To get the ItemStack that is used,
* check player.inventory.getCurrentItem()
*
* @param player
* - The player doing the wrenching
@ -28,7 +29,8 @@ public interface IToolWrench {
boolean canWrench(EntityPlayer player, int x, int y, int z);
/***
* Callback after the wrench has been used. This can be used to decrease durability or for other purposes. To get the ItemStack that was used, check
* Callback after the wrench has been used. This can be used to decrease durability or
* for other purposes. To get the ItemStack that was used, check
* player.inventory.getCurrentItem()
*
* @param player

View File

@ -3,6 +3,5 @@ package cofh.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
public interface IEnergyConnection {
boolean canConnectEnergy(ForgeDirection var1);
boolean canConnectEnergy(ForgeDirection var1);
}

View File

@ -3,10 +3,9 @@ package cofh.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
public interface IEnergyProvider extends IEnergyConnection {
int extractEnergy(ForgeDirection var1, int var2, boolean var3);
int extractEnergy(ForgeDirection var1, int var2, boolean var3);
int getEnergyStored(ForgeDirection var1);
int getEnergyStored(ForgeDirection var1);
int getMaxEnergyStored(ForgeDirection var1);
int getMaxEnergyStored(ForgeDirection var1);
}

View File

@ -3,10 +3,9 @@ package cofh.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
public interface IEnergyReceiver extends IEnergyConnection {
int receiveEnergy(ForgeDirection var1, int var2, boolean var3);
int receiveEnergy(ForgeDirection var1, int var2, boolean var3);
int getEnergyStored(ForgeDirection var1);
int getEnergyStored(ForgeDirection var1);
int getMaxEnergyStored(ForgeDirection var1);
int getMaxEnergyStored(ForgeDirection var1);
}

View File

@ -1,13 +1,11 @@
package cofh.api.energy;
public interface IEnergyStorage {
int receiveEnergy(int var1, boolean var2);
int receiveEnergy(int var1, boolean var2);
int extractEnergy(int var1, boolean var2);
int extractEnergy(int var1, boolean var2);
int getEnergyStored();
int getEnergyStored();
int getMaxEnergyStored();
int getMaxEnergyStored();
}

View File

@ -20,5 +20,7 @@ public interface IToolGrafter {
* @param z z-Coordinate of the broken leaf block.
* @return Float representing the factor the usual drop chance is to be multiplied by.
*/
float getSaplingModifier(ItemStack stack, World world, EntityPlayer player, int x, int y, int z);
float getSaplingModifier(
ItemStack stack, World world, EntityPlayer player, int x, int y, int z
);
}

View File

@ -7,7 +7,6 @@ import java.util.ArrayList;
import java.util.Iterator;
public class Config {
public static boolean hardHeat;
public static boolean hardSturdy;
public static boolean easyWing;
@ -36,19 +35,26 @@ public class Config {
public static int powerOreRarity = 8;
public static int powerOreSpawnHeight = 48;
private static void generateDefaultEngineFile() {
try {
FileWriter e = new FileWriter(engineFile);
BufferedWriter buffer = new BufferedWriter(e);
buffer.write("#Place the Forge Liquid name (all lowercase) you wish to add as a fuel or\n");
buffer.write("#throttle under the appropriate category using the below syntax.\n");
buffer.write("#The first number is the burn value and the second is burn time.\n");
buffer.write("#Liquid Force must be added as a fuel or defaults will be asserted.\n");
buffer.write(
"#Place the Forge Liquid name (all lowercase) you wish to add as a fuel or\n"
);
buffer.write(
"#throttle under the appropriate category using the below syntax.\n"
);
buffer.write(
"#The first number is the burn value and the second is burn time.\n"
);
buffer.write(
"#Liquid Force must be added as a fuel or defaults will be asserted.\n"
);
Iterator i$ = getDefaultFuels().iterator();
while(i$.hasNext()) {
String name = (String)i$.next();
while (i$.hasNext()) {
String name = (String) i$.next();
buffer.write(name);
buffer.write(10);
}
@ -57,7 +63,6 @@ public class Config {
} catch (Exception var4) {
var4.printStackTrace();
}
}
private static ArrayList getDefaultFuels() {
@ -77,23 +82,22 @@ public class Config {
}
public static ArrayList getFuels() {
/* ArrayList<String> fuels = new ArrayList<String>();
/* ArrayList<String> fuels = new ArrayList<String>();
try {
BufferedReader e = new BufferedReader(new FileReader(engineFile));
String line = null;
try {
BufferedReader e = new BufferedReader(new FileReader(engineFile));
String line = null;
while((line = e.readLine()) != null) {
if(!line.startsWith("#") && !line.startsWith("\n")) {
fuels.add("" + line);
}
}
} catch (Exception var3) {
var3.printStackTrace();
}
while((line = e.readLine()) != null) {
if(!line.startsWith("#") && !line.startsWith("\n")) {
fuels.add("" + line);
}
}
} catch (Exception var3) {
var3.printStackTrace();
}
return fuels;*/
return getDefaultFuels();
return fuels;*/
return getDefaultFuels();
}
}

View File

@ -32,9 +32,13 @@ public class Dartcraft {
public static final String VERSION = "1.0";
@Mod.Instance
public static Dartcraft instance = new Dartcraft();
public static Dartcraft instance
= new Dartcraft();
public static IRegistry registry;
@SidedProxy(serverSide = "ley.modding.dartcraft.proxy.CommonProxy", clientSide = "ley.modding.dartcraft.proxy.ClientProxy")
@SidedProxy(
serverSide = "ley.modding.dartcraft.proxy.CommonProxy",
clientSide = "ley.modding.dartcraft.proxy.ClientProxy"
)
public static CommonProxy proxy;
public static SimpleNetworkWrapper channel;
@ -45,31 +49,60 @@ public class Dartcraft {
public void preInit(FMLPreInitializationEvent e) {
MinecraftForge.EVENT_BUS.register(new EventHandler());
channel = NetworkRegistry.INSTANCE.newSimpleChannel("Dartcraft");
channel.registerMessage(PacketClipButton.Handler.class, PacketClipButton.class, 0, Side.SERVER);
channel.registerMessage(
PacketClipButton.Handler.class, PacketClipButton.class, 0, Side.SERVER
);
FortunesUtil.load();
}
@Mod.EventHandler
public void init(FMLInitializationEvent e) {
registry = new Registry();
DartItems.regsiter(registry);
DartBlocks.register(registry);
DartItems.regsiter(registry);
proxy.init();
GameRegistry.registerWorldGenerator(new OreGen(), 2);
int entityId = 0;
EntityRegistry.registerModEntity(EntityColdChicken.class, "coldChicken", entityId++, Dartcraft.instance, 40, 1, true);
EntityRegistry.registerModEntity(EntityColdCow.class, "coldCow", entityId++, Dartcraft.instance, 40, 1, true);
EntityRegistry.registerModEntity(EntityColdPig.class, "coldPig", entityId++, Dartcraft.instance, 40, 1, true);
EntityRegistry.registerModEntity(EntityBottle.class, "entityBottleItem", entityId++, Dartcraft.instance, 40, 1, true);
EntityRegistry.registerModEntity(EntityFlyingFlask.class, "entityFlyingFlask", entityId++, Dartcraft.instance, 40, 1, true);
EntityRegistry.registerModEntity(
EntityColdChicken.class,
"coldChicken",
entityId++,
Dartcraft.instance,
40,
1,
true
);
EntityRegistry.registerModEntity(
EntityColdCow.class, "coldCow", entityId++, Dartcraft.instance, 40, 1, true
);
EntityRegistry.registerModEntity(
EntityColdPig.class, "coldPig", entityId++, Dartcraft.instance, 40, 1, true
);
EntityRegistry.registerModEntity(
EntityBottle.class,
"entityBottleItem",
entityId++,
Dartcraft.instance,
40,
1,
true
);
EntityRegistry.registerModEntity(
EntityFlyingFlask.class,
"entityFlyingFlask",
entityId++,
Dartcraft.instance,
40,
1,
true
);
}
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent e) {
ForceEngineLiquids.load();
}
}

View File

@ -1,7 +1,5 @@
package ley.modding.dartcraft.api;
public interface IBaneable {
void setBaned();
void setBaned();
}

View File

@ -3,9 +3,7 @@ package ley.modding.dartcraft.api;
import net.minecraft.item.ItemStack;
public interface IBottleRenderable {
ItemStack getEntityItem();
ItemStack getEntityItem();
void setEntityItem(ItemStack var1);
void setEntityItem(ItemStack var1);
}

View File

@ -3,6 +3,5 @@ package ley.modding.dartcraft.api;
import net.minecraft.item.ItemStack;
public interface IBreakable {
ItemStack itemReturned();
ItemStack itemReturned();
}

View File

@ -3,14 +3,13 @@ package ley.modding.dartcraft.api;
import net.minecraft.item.ItemStack;
public interface IForceConsumer {
int getStored(ItemStack var1);
int getStored(ItemStack var1);
int getMaxStored(ItemStack var1);
int getMaxStored(ItemStack var1);
int amountUsedBase(ItemStack var1);
int amountUsedBase(ItemStack var1);
boolean useForce(ItemStack var1, int var2, boolean var3);
boolean useForce(ItemStack var1, int var2, boolean var3);
boolean attemptRepair(ItemStack var1);
boolean attemptRepair(ItemStack var1);
}

View File

@ -1,9 +1,7 @@
package ley.modding.dartcraft.api;
public interface IOwnedTile {
String getOwner();
String getOwner();
int getAccessLevel();
int getAccessLevel();
}

View File

@ -8,375 +8,325 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class ItemInventory implements IInventory
{
public ItemStack origin;
protected ItemStack[] contents;
private Container handler;
private String contentName;
public ItemInventory(int size)
{
this.contents = new ItemStack[size];
this.contentName = "contents";
}
public ItemInventory(int size, ItemStack stack)
{
this(size);
this.origin = stack;
public class ItemInventory implements IInventory {
public ItemStack origin;
protected ItemStack[] contents;
private Container handler;
private String contentName;
readFromNBT(stack.getTagCompound());
}
public ItemInventory(int size, ItemStack stack, String name)
{
this(size);
this.origin = stack;
this.contentName = name;
if (this.contentName == null) {
this.contentName = "contents";
public ItemInventory(int size) {
this.contents = new ItemStack[size];
this.contentName = "contents";
}
readFromNBT(stack.getTagCompound());
}
public void onGuiSaved(EntityPlayer player)
{
this.origin = findOrigin(player);
if (this.origin != null) {
save();
}
}
public ItemStack findOrigin(EntityPlayer player)
{
if (this.origin == null) {
return null;
}
NBTTagCompound comp = this.origin.getTagCompound();
if (comp == null) {
return null;
}
int id = comp.getInteger("ID");
public ItemInventory(int size, ItemStack stack) {
this(size);
this.origin = stack;
for (int i = 0; i < player.inventory.getSizeInventory(); i++)
{
if (player.inventory.getStackInSlot(i) != null)
{
NBTTagCompound playerComp = player.inventory.getStackInSlot(i).getTagCompound();
if (playerComp != null)
{
if (id == playerComp.getInteger("ID")) {
return player.inventory.getStackInSlot(i);
}
readFromNBT(stack.getTagCompound());
}
public ItemInventory(int size, ItemStack stack, String name) {
this(size);
this.origin = stack;
this.contentName = name;
if (this.contentName == null) {
this.contentName = "contents";
}
}
readFromNBT(stack.getTagCompound());
}
if (player.inventory.getItemStack() != null)
{
NBTTagCompound playerComp = player.inventory.getItemStack().getTagCompound();
if ((playerComp != null) && (id == playerComp.getInteger("ID"))) {
return player.inventory.getItemStack();
}
}
return null;
}
public boolean matchesID(int secondID)
{
if (this.origin == null) {
return false;
}
NBTTagCompound comp = this.origin.getTagCompound();
if (comp == null) {
return false;
}
int id = comp.getInteger("ID");
return id == secondID;
}
public void save()
{
if (this.origin == null) {
return;
}
NBTTagCompound comp = this.origin.getTagCompound();
if (comp == null)
comp = new NBTTagCompound();
writeToNBT(comp);
this.origin.setTagCompound(comp);
}
public void readFromNBT(NBTTagCompound comp)
{
if ((comp == null) || (this.contentName == null))
return;
if (comp.hasKey(this.contentName))
{
NBTTagList contentList = comp.getTagList(this.contentName, 10);
this.contents = new ItemStack[getSizeInventory()];
for (int i = 0; i < contentList.tagCount(); i++)
{
NBTTagCompound tempComp = contentList.getCompoundTagAt(i);
byte slotByte = tempComp.getByte("Slot");
if ((slotByte >= 0) && (slotByte < this.contents.length))
{
this.contents[slotByte] = ItemStack.loadItemStackFromNBT(tempComp);
public void onGuiSaved(EntityPlayer player) {
this.origin = findOrigin(player);
if (this.origin != null) {
save();
}
}
}
}
public void writeToNBT(NBTTagCompound comp)
{
if (this.contentName == null) {
this.contentName = "contents";
}
NBTTagList contentList = new NBTTagList();
for (int i = 0; i < this.contents.length; i++)
{
if (this.contents[i] != null)
{
NBTTagCompound tempComp = new NBTTagCompound();
tempComp.setByte("Slot", (byte)i);
this.contents[i].writeToNBT(tempComp);
contentList.appendTag(tempComp);
}
comp.setTag(this.contentName, contentList);
}
}
public ItemStack findOrigin(EntityPlayer player) {
if (this.origin == null) {
return null;
}
NBTTagCompound comp = this.origin.getTagCompound();
if (comp == null) {
return null;
}
int id = comp.getInteger("ID");
public void setCraftingListener(Container container)
{
this.handler = container;
}
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
if (player.inventory.getStackInSlot(i) != null) {
NBTTagCompound playerComp
= player.inventory.getStackInSlot(i).getTagCompound();
if (playerComp != null) {
if (id == playerComp.getInteger("ID")) {
return player.inventory.getStackInSlot(i);
}
}
}
}
public ItemStack decrStackSize(int i, int j)
{
if (this.contents[i] == null) {
return null;
if (player.inventory.getItemStack() != null) {
NBTTagCompound playerComp = player.inventory.getItemStack().getTagCompound();
if ((playerComp != null) && (id == playerComp.getInteger("ID"))) {
return player.inventory.getItemStack();
}
}
return null;
}
if (this.contents[i].stackSize <= j)
{
ItemStack product = this.contents[i];
this.contents[i] = null;
markDirty();
return product;
}
ItemStack product = this.contents[i].splitStack(j);
if (this.contents[i].stackSize == 0) {
this.contents[i] = null;
}
markDirty();
return product;
}
public ItemStack getStackInSlotOnClosing(int slot)
{
if (this.contents[slot] == null)
return null;
ItemStack returnVal = this.contents[slot];
this.contents[slot] = null;
markDirty();
return returnVal;
}
public boolean matchesID(int secondID) {
if (this.origin == null) {
return false;
}
NBTTagCompound comp = this.origin.getTagCompound();
if (comp == null) {
return false;
}
int id = comp.getInteger("ID");
return id == secondID;
}
public void setInventorySlotContents(int index, ItemStack stack)
{
this.contents[index] = stack;
markDirty();
}
public void save() {
if (this.origin == null) {
return;
}
NBTTagCompound comp = this.origin.getTagCompound();
if (comp == null)
comp = new NBTTagCompound();
writeToNBT(comp);
this.origin.setTagCompound(comp);
}
public int getFirstEmptyStack()
{
for (int i = 0; i < this.contents.length; i++) {
if (this.contents[i] == null)
return i;
}
return -1;
}
public void readFromNBT(NBTTagCompound comp) {
if ((comp == null) || (this.contentName == null))
return;
if (comp.hasKey(this.contentName)) {
NBTTagList contentList = comp.getTagList(this.contentName, 10);
this.contents = new ItemStack[getSizeInventory()];
for (int i = 0; i < contentList.tagCount(); i++) {
NBTTagCompound tempComp = contentList.getCompoundTagAt(i);
byte slotByte = tempComp.getByte("Slot");
public int getFreeSlots()
{
int free = 0;
if ((this.contents != null) && (this.contents.length > 0)) {
for (ItemStack checkStack : this.contents)
if (checkStack == null)
free++;
if ((slotByte >= 0) && (slotByte < this.contents.length)) {
this.contents[slotByte] = ItemStack.loadItemStackFromNBT(tempComp);
}
}
}
}
return free;
}
private int storePartialItemStack(ItemStack stack)
{
Item i = stack.getItem();
int j = stack.stackSize;
public void writeToNBT(NBTTagCompound comp) {
if (this.contentName == null) {
this.contentName = "contents";
}
NBTTagList contentList = new NBTTagList();
for (int i = 0; i < this.contents.length; i++) {
if (this.contents[i] != null) {
NBTTagCompound tempComp = new NBTTagCompound();
tempComp.setByte("Slot", (byte) i);
if (stack.getMaxStackSize() == 1)
{
int k = getFirstEmptyStack();
if (k < 0) {
return j;
}
if (this.contents[k] == null) {
this.contents[k] = ItemStack.copyItemStack(stack);
}
return 0;
}
this.contents[i].writeToNBT(tempComp);
contentList.appendTag(tempComp);
}
comp.setTag(this.contentName, contentList);
}
}
int k = storeItemStack(stack);
if (k < 0) {
k = getFirstEmptyStack();
public void setCraftingListener(Container container) {
this.handler = container;
}
if (k < 0) {
return j;
}
if (this.contents[k] == null)
{
this.contents[k] = new ItemStack(i, 0, stack.getItemDamage());
if (stack.hasTagCompound()) {
this.contents[k].setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
}
}
int l = j;
if (j > this.contents[k].getMaxStackSize() - this.contents[k].stackSize) {
l = this.contents[k].getMaxStackSize() - this.contents[k].stackSize;
}
if (l > getInventoryStackLimit() - this.contents[k].stackSize) {
l = getInventoryStackLimit() - this.contents[k].stackSize;
}
if (l == 0) {
return j;
}
j -= l;
this.contents[k].stackSize += l;
this.contents[k].animationsToGo = 5;
return j;
}
public int storeItemStack(ItemStack stack)
{
for (int i = 0; i < this.contents.length; i++) {
if ((this.contents[i] != null) && (this.contents[i].getItem() == stack.getItem()) && (this.contents[i].isStackable()) && (this.contents[i].stackSize < this.contents[i].getMaxStackSize()) && (this.contents[i].stackSize < getInventoryStackLimit()) && ((!this.contents[i].getHasSubtypes()) || (this.contents[i].getItemDamage() == stack.getItemDamage())) && (ItemStack.areItemStackTagsEqual(this.contents[i], stack)))
{
return i;
}
}
return -1;
}
public ItemStack decrStackSize(int i, int j) {
if (this.contents[i] == null) {
return null;
}
if (this.contents[i].stackSize <= j) {
ItemStack product = this.contents[i];
this.contents[i] = null;
markDirty();
return product;
}
public boolean addItemToInventory(ItemStack stack)
{
if (stack == null) {
return false;
}
if (stack.isItemDamaged())
{
int i = getFirstEmptyStack();
if (i >= 0)
{
this.contents[i] = ItemStack.copyItemStack(stack);
this.contents[i].animationsToGo = 5;
stack.stackSize = 0;
ItemStack product = this.contents[i].splitStack(j);
if (this.contents[i].stackSize == 0) {
this.contents[i] = null;
}
markDirty();
return product;
}
public ItemStack getStackInSlotOnClosing(int slot) {
if (this.contents[slot] == null)
return null;
ItemStack returnVal = this.contents[slot];
this.contents[slot] = null;
markDirty();
return returnVal;
}
public void setInventorySlotContents(int index, ItemStack stack) {
this.contents[index] = stack;
markDirty();
}
public int getFirstEmptyStack() {
for (int i = 0; i < this.contents.length; i++) {
if (this.contents[i] == null)
return i;
}
return -1;
}
public int getFreeSlots() {
int free = 0;
if ((this.contents != null) && (this.contents.length > 0)) {
for (ItemStack checkStack : this.contents)
if (checkStack == null)
free++;
}
return free;
}
private int storePartialItemStack(ItemStack stack) {
Item i = stack.getItem();
int j = stack.stackSize;
if (stack.getMaxStackSize() == 1) {
int k = getFirstEmptyStack();
if (k < 0) {
return j;
}
if (this.contents[k] == null) {
this.contents[k] = ItemStack.copyItemStack(stack);
}
return 0;
}
int k = storeItemStack(stack);
if (k < 0) {
k = getFirstEmptyStack();
}
if (k < 0) {
return j;
}
if (this.contents[k] == null) {
this.contents[k] = new ItemStack(i, 0, stack.getItemDamage());
if (stack.hasTagCompound()) {
this.contents[k].setTagCompound(
(NBTTagCompound) stack.getTagCompound().copy()
);
}
}
int l = j;
if (j > this.contents[k].getMaxStackSize() - this.contents[k].stackSize) {
l = this.contents[k].getMaxStackSize() - this.contents[k].stackSize;
}
if (l > getInventoryStackLimit() - this.contents[k].stackSize) {
l = getInventoryStackLimit() - this.contents[k].stackSize;
}
if (l == 0) {
return j;
}
j -= l;
this.contents[k].stackSize += l;
this.contents[k].animationsToGo = 5;
return j;
}
public int storeItemStack(ItemStack stack) {
for (int i = 0; i < this.contents.length; i++) {
if ((this.contents[i] != null)
&& (this.contents[i].getItem() == stack.getItem())
&& (this.contents[i].isStackable())
&& (this.contents[i].stackSize < this.contents[i].getMaxStackSize())
&& (this.contents[i].stackSize < getInventoryStackLimit())
&& ((!this.contents[i].getHasSubtypes())
|| (this.contents[i].getItemDamage() == stack.getItemDamage()))
&& (ItemStack.areItemStackTagsEqual(this.contents[i], stack))) {
return i;
}
}
return -1;
}
public boolean addItemToInventory(ItemStack stack) {
if (stack == null) {
return false;
}
if (stack.isItemDamaged()) {
int i = getFirstEmptyStack();
if (i >= 0) {
this.contents[i] = ItemStack.copyItemStack(stack);
this.contents[i].animationsToGo = 5;
stack.stackSize = 0;
markDirty();
return true;
}
return false;
}
int i;
do {
i = stack.stackSize;
stack.stackSize = storePartialItemStack(stack);
} while ((stack.stackSize > 0) && (stack.stackSize < i));
return stack.stackSize < i;
}
public ItemStack getStackInSlot(int index) {
return this.contents[index];
}
public int getSizeInventory() {
return this.contents.length;
}
public String getInventoryName() {
return "inventory.simulated";
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
public int getInventoryStackLimit() {
return 64;
}
public void markDirty() {
if (this.handler != null) {
this.handler.onCraftMatrixChanged(this);
}
}
public boolean isUseableByPlayer(EntityPlayer player) {
return true;
}
return false;
}
int i;
do
{
i = stack.stackSize;
stack.stackSize = storePartialItemStack(stack);
@Override
public void openInventory() {}
@Override
public void closeInventory() {}
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return false;
}
while ((stack.stackSize > 0) && (stack.stackSize < i));
return stack.stackSize < i;
}
public ItemStack getStackInSlot(int index)
{
return this.contents[index];
}
public int getSizeInventory() { return this.contents.length; }
public String getInventoryName() {
return "inventory.simulated";
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
public int getInventoryStackLimit() { return 64; }
public void markDirty()
{
if (this.handler != null) {
this.handler.onCraftMatrixChanged(this);
}
}
public boolean isUseableByPlayer(EntityPlayer player)
{
return true;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
return false;
}
}

View File

@ -1,7 +1,5 @@
package ley.modding.dartcraft.api.upgrades;
public interface IForceUpgradable {
int[] validUpgrades();
int[] validUpgrades();
}

View File

@ -3,76 +3,80 @@ package ley.modding.dartcraft.api.upgrades;
import java.util.ArrayList;
public class IForceUpgrade {
private int id = getUniqueUpgradeID();
private String name;
private String description;
private int tier;
private int maxLevel;
private ArrayList materials = new ArrayList();
private int id = getUniqueUpgradeID();
private String name;
private String description;
private int tier;
private int maxLevel;
private ArrayList materials = new ArrayList();
public IForceUpgrade(int tier, String name, int maxLevel, String description) {
this.tier = tier;
this.name = name;
this.maxLevel = maxLevel;
this.description = description;
}
public void addMat(IForceUpgradeMaterial mat) {
if (mat != null && this.materials != null) {
this.materials.add(mat);
}
}
public IForceUpgrade(int tier, String name, int maxLevel, String description) {
this.tier = tier;
this.name = name;
this.maxLevel = maxLevel;
this.description = description;
}
public int getID() {
return this.id;
}
public void addMat(IForceUpgradeMaterial mat) {
if(mat != null && this.materials != null) {
this.materials.add(mat);
}
public int getTier() {
return this.tier;
}
}
public String getName() {
return this.name;
}
public int getID() {
return this.id;
}
public String getDescription() {
return this.description;
}
public int getTier() {
return this.tier;
}
public int getMaxLevel() {
return this.maxLevel;
}
public String getName() {
return this.name;
}
public int getNumMats() {
return this.materials != null ? this.materials.size() : 0;
}
public String getDescription() {
return this.description;
}
public static int getUniqueUpgradeID() {
try {
return 1; //((Integer)ReflectionHelper.getMethod(DartAPI.manager,
//"getFirstUniqueUpgradeID", new Class[0]).invoke(DartAPI.manager,
//new Object[0])).intValue();
} catch (Exception var1) {
var1.printStackTrace();
return -1;
}
}
public int getMaxLevel() {
return this.maxLevel;
}
public IForceUpgradeMaterial getMaterialAt(int index) {
return this.materials != null && this.materials.size() > index
? (IForceUpgradeMaterial) this.materials.get(index)
: null;
}
public int getNumMats() {
return this.materials != null?this.materials.size():0;
}
public static int getUniqueUpgradeID() {
try {
return 1; //((Integer)ReflectionHelper.getMethod(DartAPI.manager, "getFirstUniqueUpgradeID", new Class[0]).invoke(DartAPI.manager, new Object[0])).intValue();
} catch (Exception var1) {
var1.printStackTrace();
return -1;
}
}
public IForceUpgradeMaterial getMaterialAt(int index) {
return this.materials != null && this.materials.size() > index?(IForceUpgradeMaterial)this.materials.get(index):null;
}
public int getMaterialIndex(IForceUpgradeMaterial mat) {
if(this.materials != null && this.materials.size() > 0) {
for(int i = 0; i < this.materials.size(); ++i) {
IForceUpgradeMaterial check = (IForceUpgradeMaterial)this.materials.get(i);
if(check.getUpgradeID() == mat.getUpgradeID() && check.getItem() == mat.getItem() && check.getItemMeta() == mat.getItemMeta()) {
return i;
public int getMaterialIndex(IForceUpgradeMaterial mat) {
if (this.materials != null && this.materials.size() > 0) {
for (int i = 0; i < this.materials.size(); ++i) {
IForceUpgradeMaterial check
= (IForceUpgradeMaterial) this.materials.get(i);
if (check.getUpgradeID() == mat.getUpgradeID()
&& check.getItem() == mat.getItem()
&& check.getItemMeta() == mat.getItemMeta()) {
return i;
}
}
}
}
}
return -1;
}
return -1;
}
}

View File

@ -1,21 +1,19 @@
package ley.modding.dartcraft.api.upgrades;
import net.minecraft.item.Item;
public interface IForceUpgradeMaterial {
Item getItem();
Item getItem();
int getItemMeta();
int getItemMeta();
int getUpgradeID();
int getUpgradeID();
int getBonus();
int getBonus();
float getEfficiency();
float getEfficiency();
String getDescription();
String getDescription();
boolean isRequired();
boolean isRequired();
}

View File

@ -3,76 +3,103 @@ package ley.modding.dartcraft.api.upgrades;
import ley.modding.dartcraft.util.ForceUpgradeManager;
import net.minecraft.item.Item;
public class UpgradeMaterialHelper
{
public class UpgradeMaterialHelper {
public static IForceUpgradeMaterial createMaterial(
Item item,
int upgradeID,
int bonus,
float efficiency,
String description,
boolean required
) {
try {
if (ForceUpgradeManager.getFromID(upgradeID) == null)
return null;
return new UpgradeAdapter(
item, 0, upgradeID, bonus, efficiency, description, required
);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static IForceUpgradeMaterial createMaterial(Item item, int upgradeID, int bonus, float efficiency, String description, boolean required) {
try {
if (ForceUpgradeManager.getFromID(upgradeID) == null)
return null;
return new UpgradeAdapter(item, 0, upgradeID, bonus, efficiency, description, required);
} catch (Exception e) {
e.printStackTrace();
return null;
public static IForceUpgradeMaterial createMaterial(
Item item,
int meta,
int upgradeID,
int bonus,
float efficiency,
String description,
boolean required
) {
try {
if (ForceUpgradeManager.getFromID(upgradeID) == null)
return null;
return new UpgradeAdapter(
item, meta, upgradeID, bonus, efficiency, description, required
);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
public static IForceUpgradeMaterial createMaterial(Item item, int meta, int upgradeID, int bonus, float efficiency, String description, boolean required) {
try {
if (ForceUpgradeManager.getFromID(upgradeID) == null)
return null;
return new UpgradeAdapter(item, meta, upgradeID, bonus, efficiency, description, required);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private static class UpgradeAdapter implements IForceUpgradeMaterial {
private Item item;
private static class UpgradeAdapter
implements IForceUpgradeMaterial
{
private Item item;
private int meta;
private int upgradeID;
private int bonus;
private float efficiency;
private String description;
private boolean required;
public UpgradeAdapter(Item item, int meta, int upgradeID, int bonus, float efficiency, String description, boolean required)
{
this.item = item;
this.meta = meta;
this.upgradeID = upgradeID;
this.bonus = bonus;
this.efficiency = efficiency;
this.description = description;
this.required = required;
private int meta;
private int upgradeID;
private int bonus;
private float efficiency;
private String description;
private boolean required;
public UpgradeAdapter(
Item item,
int meta,
int upgradeID,
int bonus,
float efficiency,
String description,
boolean required
) {
this.item = item;
this.meta = meta;
this.upgradeID = upgradeID;
this.bonus = bonus;
this.efficiency = efficiency;
this.description = description;
this.required = required;
}
public int getUpgradeID() {
return this.upgradeID;
}
public int getBonus() {
return this.bonus;
}
public float getEfficiency() {
return this.efficiency;
}
public Item getItem() {
return this.item;
}
public int getItemMeta() {
return this.meta;
}
public String getDescription() {
return this.description;
}
public boolean isRequired() {
return this.required;
}
}
public int getUpgradeID() {
return this.upgradeID;
}
public int getBonus() { return this.bonus; }
public float getEfficiency() {
return this.efficiency;
}
public Item getItem() { return this.item; }
public int getItemMeta() {
return this.meta;
}
public String getDescription() { return this.description; }
public boolean isRequired() {
return this.required;
}
}
}

View File

@ -0,0 +1,155 @@
package ley.modding.dartcraft.block;
import java.util.List;
import java.util.stream.IntStream;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ley.modding.dartcraft.item.ItemBlockForceBrick;
import ley.modding.dartcraft.util.DartUtils;
import ley.modding.dartcraft.util.FXUtils;
import ley.modding.dartcraft.util.Util;
import ley.modding.tileralib.api.ICustomItemBlockProvider;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockForceBrick extends Block implements ICustomItemBlockProvider {
public IIcon[] icons;
public BlockForceBrick() {
super(Material.rock);
Util.configureBlock(this, "forcebrick");
this.setHardness(2.0F);
this.setResistance(2000.0F);
this.setStepSound(Block.soundTypeStone);
}
@Override
public boolean
canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
return false;
}
@Override
public IIcon getIcon(int side, int meta) {
return meta >= 0 && meta < 16 ? this.icons[meta] : this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
public void getSubBlocks(Item par1, CreativeTabs tab, List list) {
IntStream.range(0, 16)
.mapToObj(i -> new ItemStack(this, 1, i))
.forEach(list::add);
}
@Override
public int damageDropped(int meta) {
return meta;
}
@Override
public void
onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
this.velocityToAddToEntity(world, x, y, z, entity, (Vec3) null);
}
@Override
public void
velocityToAddToEntity(World world, int x, int y, int z, Entity entity, Vec3 vec) {
double skateLimit = 0.5D;
double step = 0.025D;
entity.addVelocity(step * entity.motionX, 0.0D, step * entity.motionZ);
if (entity.motionX > skateLimit) {
entity.motionX = skateLimit;
}
if (entity.motionX < -skateLimit) {
entity.motionX = -skateLimit;
}
if (entity.motionY > skateLimit) {
entity.motionY = skateLimit;
}
if (entity.motionY < -skateLimit) {
entity.motionY = -skateLimit;
}
if (entity.motionZ > skateLimit) {
entity.motionZ = skateLimit;
}
if (entity.motionZ < -skateLimit) {
entity.motionZ = -skateLimit;
}
}
// TODO: WTF
//@Override
@SideOnly(Side.CLIENT)
public boolean addBlockDestroyEffects(
World world, int x, int y, int z, int meta, EffectRenderer renderer
) {
int color = world.getBlockMetadata(x, y, z);
FXUtils.makeShiny(
world,
(double) x,
(double) y,
(double) z,
2,
DartUtils.getMcColor(color),
32,
true
);
return true;
}
// TODO: WTF
//@Override
@SideOnly(Side.CLIENT)
public boolean addBlockHitEffects(
World world, MovingObjectPosition target, EffectRenderer renderer
) {
int color = world.getBlockMetadata(target.blockX, target.blockY, target.blockZ);
FXUtils.makeShiny(
world,
(double) target.blockX,
(double) target.blockY,
(double) target.blockZ,
2,
DartUtils.getMcColor(color),
4,
true
);
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reggie) {
this.icons = IntStream.range(0, 16)
.mapToObj(i -> "dartcraft:brick" + i)
.map(reggie::registerIcon)
.toArray(IIcon[] ::new);
}
@Override
public Class<? extends ItemBlock> getItemBlockClass() {
return ItemBlockForceBrick.class;
}
}

View File

@ -21,7 +21,6 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
public class BlockForceEngine extends BlockContainer implements ITEProvider {
public BlockForceEngine() {
super(Material.iron);
setHardness(3.0F);
@ -34,27 +33,40 @@ public class BlockForceEngine extends BlockContainer implements ITEProvider {
return new TileEntityForceEngine();
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
if(!Dartcraft.proxy.isSimulating(world)) {
public boolean onBlockActivated(
World world,
int x,
int y,
int z,
EntityPlayer player,
int par6,
float par7,
float par8,
float par9
) {
if (!Dartcraft.proxy.isSimulating(world)) {
return true;
} else {
TileEntity tile = world.getTileEntity(x, y, z);
TileEntityForceEngine engine = null;
if(tile instanceof TileEntityForceEngine) {
engine = (TileEntityForceEngine)tile;
if (tile instanceof TileEntityForceEngine) {
engine = (TileEntityForceEngine) tile;
}
if(engine != null) {
if(DartUtils.isHoldingWrench(player)) {
if (engine != null) {
if (DartUtils.isHoldingWrench(player)) {
engine.rotateBlock();
return true;
}
if(player.getCurrentEquippedItem() != null && FluidContainerRegistry.getFluidForFilledItem(player.getCurrentEquippedItem()) != null) {
if (player.getCurrentEquippedItem() != null
&& FluidContainerRegistry.getFluidForFilledItem(
player.getCurrentEquippedItem()
) != null) {
return DartUtils.fillTankWithContainer(engine, player);
}
if(!player.isSneaking() && !DartUtils.isHoldingWrench(player)) {
if (!player.isSneaking() && !DartUtils.isHoldingWrench(player)) {
player.openGui(Dartcraft.instance, 7, world, x, y, z);
}
}
@ -63,18 +75,21 @@ public class BlockForceEngine extends BlockContainer implements ITEProvider {
}
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) {
TileEntityForceEngine tile = (TileEntityForceEngine)world.getTileEntity(x, y, z);
if(tile != null) {
public void onBlockPlacedBy(
World world, int x, int y, int z, EntityLivingBase living, ItemStack stack
) {
TileEntityForceEngine tile = (TileEntityForceEngine) world.getTileEntity(x, y, z);
if (tile != null) {
tile.setFacing(ForgeDirection.UP);
tile.rotateBlock();
}
}
public int getLightValue(IBlockAccess world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
return te instanceof TileEntityForceEngine?((TileEntityForceEngine)te).getLightValue():0;
return te instanceof TileEntityForceEngine
? ((TileEntityForceEngine) te).getLightValue()
: 0;
}
public int getRenderType() {
@ -90,14 +105,14 @@ public class BlockForceEngine extends BlockContainer implements ITEProvider {
}
public void breakBlock(World world, int x, int y, int z, Block par5, int par6) {
if(Dartcraft.proxy.isSimulating(world)) {
if (Dartcraft.proxy.isSimulating(world)) {
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityForceEngine) {
TileEntityForceEngine engine = (TileEntityForceEngine)tile;
if (tile instanceof TileEntityForceEngine) {
TileEntityForceEngine engine = (TileEntityForceEngine) tile;
for(int i = 0; i < engine.liquidInventory.getSizeInventory(); ++i) {
for (int i = 0; i < engine.liquidInventory.getSizeInventory(); ++i) {
ItemStack tempStack = engine.liquidInventory.getStackInSlot(i);
if(tempStack != null) {
if (tempStack != null) {
DartUtils.dropItem(tempStack, world, x, y, z);
}
}
@ -108,21 +123,29 @@ public class BlockForceEngine extends BlockContainer implements ITEProvider {
}
@Override
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
public boolean
isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
TileEntity tile = world.getTileEntity(x, y, z);
return tile instanceof TileEntityForceEngine ?((TileEntityForceEngine)tile).facing.getOpposite() == side:false;
return tile instanceof TileEntityForceEngine
? ((TileEntityForceEngine) tile).facing.getOpposite() == side
: false;
}
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer renderer) {
//FXUtils.makeShiny(world, (double)x, (double)y, (double)z, 2, 16776960, 16, true);
public boolean addDestroyEffects(
World world, int x, int y, int z, int meta, EffectRenderer renderer
) {
//FXUtils.makeShiny(world, (double)x, (double)y, (double)z, 2, 16776960, 16,
//true);
return true;
}
@SideOnly(Side.CLIENT)
public boolean addHitEffects(World world, MovingObjectPosition target, EffectRenderer renderer) {
if(world != null && target != null) { //TODO FX
//FXUtils.makeShiny(world, (double)target.blockX, (double)target.blockY, (double)target.blockZ, 2, 16776960, 3, true);
public boolean
addHitEffects(World world, MovingObjectPosition target, EffectRenderer renderer) {
if (world != null && target != null) { //TODO FX
//FXUtils.makeShiny(world, (double)target.blockX, (double)target.blockY,
//(double)target.blockZ, 2, 16776960, 3, true);
}
return true;
}

View File

@ -32,39 +32,45 @@ public class BlockForceLeaves extends BlockLeaves {
@SideOnly(Side.CLIENT)
@Override
public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) {
public boolean shouldSideBeRendered(
IBlockAccess p_149646_1_,
int p_149646_2_,
int p_149646_3_,
int p_149646_4_,
int p_149646_5_
) {
return true;
}
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
return this.icon;
}
@Override
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
return this.icon;
}
// this seems to be getting the variants or something...
@SideOnly(Side.CLIENT)
@Override
public String[] func_150125_e() {
return new String[]{"force"};
}
@Override
public String[] func_150125_e() {
return new String[] { "force" };
}
@SideOnly(Side.CLIENT)
@Override
public int getBlockColor()
{
public int getBlockColor() {
return 0xffffff;
}
@SideOnly(Side.CLIENT)
public int getRenderColor(int p_149741_1_)
{
public int getRenderColor(int p_149741_1_) {
return 0xffffff;
}
@SideOnly(Side.CLIENT)
@Override
public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) {
public int colorMultiplier(
IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_
) {
return 0xffffff;
}
@ -72,5 +78,4 @@ public class BlockForceLeaves extends BlockLeaves {
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return Item.getItemFromBlock(DartBlocks.forcesapling);
}
}

View File

@ -28,11 +28,12 @@ public class BlockForceSapling extends BlockSapling {
// generate tree
@Override
public void func_149878_d(World world, int x, int y, int z, Random rand) {
if (!TerrainGen.saplingGrowTree(world, rand, x, y, z)) return;
if (!TerrainGen.saplingGrowTree(world, rand, x, y, z))
return;
world.setBlockToAir(x, y, z);
new GenForceTree(true).generate(world, rand, x, y, z);
}
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
list.add(new ItemStack(item));

View File

@ -24,7 +24,6 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
public class BlockLiquidForce extends BlockFluidClassic {
public IIcon still;
public IIcon flowing;
public IIcon milk;
@ -42,7 +41,8 @@ public class BlockLiquidForce extends BlockFluidClassic {
return 15;
}
public void velocityToAddToEntity(World world, int x, int y, int z, Entity entity, Vec3 vec) {
public void
velocityToAddToEntity(World world, int x, int y, int z, Entity entity, Vec3 vec) {
if (entity == null)
return;
try {
@ -53,16 +53,20 @@ public class BlockLiquidForce extends BlockFluidClassic {
} catch (Exception e) {}
}
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
public void
onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
try {
if (entity instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase)entity;
if (living.isEntityUndead() || living instanceof net.minecraft.entity.monster.EntityBlaze) {
living.addPotionEffect(new PotionEffect(Potion.weakness.getId(), 1, 9, false));
EntityLivingBase living = (EntityLivingBase) entity;
if (living.isEntityUndead()
|| living instanceof net.minecraft.entity.monster.EntityBlaze) {
living.addPotionEffect(
new PotionEffect(Potion.weakness.getId(), 1, 9, false)
);
/*if (Config.baneForce) {
living.attackEntityFrom((DamageSource) PunishDamage.instance, 2.0F);
} else {*/
living.attackEntityFrom(DamageSource.magic, 2.0F);
living.attackEntityFrom((DamageSource)
PunishDamage.instance, 2.0F); } else {*/
living.attackEntityFrom(DamageSource.magic, 2.0F);
//}
} else {
if (living.getAir() < 255)
@ -73,26 +77,37 @@ public class BlockLiquidForce extends BlockFluidClassic {
}
if (Dartcraft.proxy.isSimulating(world)) {
float chance = 0.9925F;
if (living instanceof EntityColdCow && living.getRNG().nextFloat() > chance) {
EntityColdCow cow = (EntityColdCow)living;
if (living instanceof EntityColdCow
&& living.getRNG().nextFloat() > chance) {
EntityColdCow cow = (EntityColdCow) living;
//cow.shouldRevert = true;
}
if (living instanceof EntityColdChicken && living.getRNG().nextFloat() > chance) {
EntityColdChicken chicken = (EntityColdChicken)living;
if (living instanceof EntityColdChicken
&& living.getRNG().nextFloat() > chance) {
EntityColdChicken chicken = (EntityColdChicken) living;
//chicken.shouldRevert = true;
}
if (living instanceof EntityColdPig && living.getRNG().nextFloat() > chance) {
EntityColdPig pig = (EntityColdPig)living;
if (living instanceof EntityColdPig
&& living.getRNG().nextFloat() > chance) {
EntityColdPig pig = (EntityColdPig) living;
//pig.shouldRevert = true;
}
if (living instanceof EntitySheep && living.getRNG().nextFloat() > chance) {
EntitySheep sheep = (EntitySheep)living;
if (living instanceof EntitySheep
&& living.getRNG().nextFloat() > chance) {
EntitySheep sheep = (EntitySheep) living;
sheep.eatGrassBonus();
}
if (living instanceof EntityAgeable && !(living instanceof net.minecraft.entity.passive.EntityHorse)) {
EntityAgeable animal = (EntityAgeable)living;
if (living instanceof EntityAgeable
&& !(
living instanceof net.minecraft.entity.passive.EntityHorse
)) {
EntityAgeable animal = (EntityAgeable) living;
if (animal.getGrowingAge() < 0)
animal.setGrowingAge((animal.getGrowingAge() < -20) ? (animal.getGrowingAge() + 20) : 0);
animal.setGrowingAge(
(animal.getGrowingAge() < -20)
? (animal.getGrowingAge() + 20)
: 0
);
}
}
}
@ -118,4 +133,3 @@ public class BlockLiquidForce extends BlockFluidClassic {
}
}
}

View File

@ -18,7 +18,6 @@ import java.util.List;
import java.util.Random;
public class BlockPowerOre extends Block {
public static IIcon stoneicon;
public static IIcon nethericon;
public static IIcon powericon;
@ -62,16 +61,15 @@ public class BlockPowerOre extends Block {
}
@Override
public void dropXpOnBlockBreak(World world, int x, int y, int z, int exp)
{
public void dropXpOnBlockBreak(World world, int x, int y, int z, int exp) {
exp = world.rand.nextInt(3) + 2;
if (Dartcraft.proxy.isSimulating(world))
{
while (exp > 0)
{
if (Dartcraft.proxy.isSimulating(world)) {
while (exp > 0) {
int amt = EntityXPOrb.getXPSplit(exp);
exp -= amt;
world.spawnEntityInWorld(new EntityXPOrb(world, x + 0.5D, y + 0.5D, z + 0.5D, amt));
world.spawnEntityInWorld(
new EntityXPOrb(world, x + 0.5D, y + 0.5D, z + 0.5D, amt)
);
}
}
}

View File

@ -6,12 +6,13 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
public class DartBlocks {
public static Block powerore;
public static Block forcesapling;
public static Block forcelog;
public static Block forceleaves;
public static Block engine;
public static Block forcebrick;
public static Block forceleaves;
public static Block forcelog;
public static Block forcesapling;
public static Block liquidforce;
public static Block powerore;
public static void register(IRegistry reg) {
FluidRegistry.registerFluid(new FluidLiquidForce());
@ -19,11 +20,13 @@ public class DartBlocks {
Fluid milk = new Fluid("milk");
FluidRegistry.registerFluid(milk);
}
DartBlocks.liquidforce = reg.registerBlock(new BlockLiquidForce());
DartBlocks.forcesapling = reg.registerBlock(new BlockForceSapling());
DartBlocks.powerore = reg.registerBlock(new BlockPowerOre());
DartBlocks.forcelog = reg.registerBlock(new BlockForceLog());
DartBlocks.forceleaves = reg.registerBlock(new BlockForceLeaves());
DartBlocks.engine = reg.registerBlock(new BlockForceEngine());
DartBlocks.forcebrick = reg.registerBlock(new BlockForceBrick());
DartBlocks.forceleaves = reg.registerBlock(new BlockForceLeaves());
DartBlocks.forcelog = reg.registerBlock(new BlockForceLog());
DartBlocks.forcesapling = reg.registerBlock(new BlockForceSapling());
DartBlocks.liquidforce = reg.registerBlock(new BlockLiquidForce());
DartBlocks.powerore = reg.registerBlock(new BlockPowerOre());
}
}

View File

@ -1,6 +1,5 @@
package ley.modding.dartcraft.client.gui;
import ley.modding.dartcraft.Dartcraft;
import ley.modding.dartcraft.item.ItemClipboard;
import ley.modding.dartcraft.util.ItemCraftingInventory;
@ -41,25 +40,37 @@ public class ContainerClipboard extends Container {
this.hasInitialized = false;
this.contents = inv;
this.user = player;
this.playerInv = (IInventory)player.inventory;
this.playerInv = (IInventory) player.inventory;
this.contents.setCraftingListener(this);
this.neiBuffer = new ItemStack[9];
int i;
for (i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++)
addSlotToContainer(new ClipSlot((IInventory)this.contents, i * 3 + j, 25 + j * 18, 12 + i * 18));
addSlotToContainer(new ClipSlot(
(IInventory) this.contents, i * 3 + j, 25 + j * 18, 12 + i * 18
));
}
addSlotToContainer((Slot)new ClipSlotCrafting(this.user, (IInventory)this.contents, (IInventory)this.craftResult, 0, 113, 30));
addSlotToContainer((Slot) new ClipSlotCrafting(
this.user,
(IInventory) this.contents,
(IInventory) this.craftResult,
0,
113,
30
));
for (i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++)
addSlotToContainer(new Slot(this.playerInv, 9 + i * 9 + j, 8 + 18 * j, 75 + 18 * i));
addSlotToContainer(
new Slot(this.playerInv, 9 + i * 9 + j, 8 + 18 * j, 75 + 18 * i)
);
}
for (i = 0; i < 9; i++)
addSlotToContainer(new Slot(this.playerInv, i, 8 + 18 * i, 133));
this.hasInitialized = true;
onCraftMatrixChanged((IInventory)this.contents);
onCraftMatrixChanged((IInventory) this.contents);
this.originStack = inv.parent;
if (this.originStack == null || !(this.originStack.getItem() instanceof ItemClipboard))
if (this.originStack == null
|| !(this.originStack.getItem() instanceof ItemClipboard))
player.closeScreen();
this.useInventory = this.originStack.getTagCompound().getBoolean("useInventory");
canStayOpen(player);
@ -68,7 +79,12 @@ public class ContainerClipboard extends Container {
public void onCraftMatrixChanged(IInventory inv) {
if (!this.hasInitialized)
return;
this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe((InventoryCrafting) this.contents, ((Entity)this.user).worldObj));
this.craftResult.setInventorySlotContents(
0,
CraftingManager.getInstance().findMatchingRecipe(
(InventoryCrafting) this.contents, ((Entity) this.user).worldObj
)
);
}
public ItemStack slotClick(int slot, int button, int par3, EntityPlayer player) {
@ -103,7 +119,8 @@ public class ContainerClipboard extends Container {
if (!mergeItemStack(stack, 10, 46, true))
return null;
if (index == 9) {
int maxCraftable = this.craftResult.getStackInSlot(0).getMaxStackSize() / (this.craftResult.getStackInSlot(0)).stackSize;
int maxCraftable = this.craftResult.getStackInSlot(0).getMaxStackSize()
/ (this.craftResult.getStackInSlot(0)).stackSize;
int i;
for (i = 0; i < 9; i++) {
ItemStack tempStack = this.contents.getStackInSlot(i);
@ -126,7 +143,7 @@ public class ContainerClipboard extends Container {
return null;
}
if (stack.stackSize == 0) {
slot.putStack((ItemStack)null);
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
@ -144,12 +161,13 @@ public class ContainerClipboard extends Container {
public void onContainerClosed(EntityPlayer player) {
super.onContainerClosed(player);
if (!Dartcraft.proxy.isSimulating(((Entity)player).worldObj))
if (!Dartcraft.proxy.isSimulating(((Entity) player).worldObj))
return;
this.contents.onGuiSaved(player);
}
protected void retrySlotClick(int par1, int par2, boolean par3, EntityPlayer par4EntityPlayer) {}
protected void
retrySlotClick(int par1, int par2, boolean par3, EntityPlayer par4EntityPlayer) {}
public void grabItems(ItemStack[] items) {
if (items == null || items.length != 9 || this.contents == null)
@ -166,8 +184,12 @@ public class ContainerClipboard extends Container {
boolean found = false;
int j;
for (j = 0; j < this.user.inventory.mainInventory.length; j++) {
if (isItemEquivalent(items[i], this.user.inventory.mainInventory[j])) {
this.contents.setInventorySlotContents(i, this.user.inventory.mainInventory[j].copy());
if (isItemEquivalent(
items[i], this.user.inventory.mainInventory[j]
)) {
this.contents.setInventorySlotContents(
i, this.user.inventory.mainInventory[j].copy()
);
this.user.inventory.mainInventory[j] = null;
found = true;
break;
@ -179,7 +201,9 @@ public class ContainerClipboard extends Container {
break;
if (isItemEquivalent(items[i], this.contents.getStackInSlot(j)))
if ((this.contents.getStackInSlot(j)).stackSize > 1) {
this.contents.setInventorySlotContents(i, this.contents.getStackInSlot(j).copy());
this.contents.setInventorySlotContents(
i, this.contents.getStackInSlot(j).copy()
);
(this.contents.getStackInSlot(i)).stackSize = 1;
(this.contents.getStackInSlot(j)).stackSize--;
break;
@ -194,8 +218,8 @@ public class ContainerClipboard extends Container {
ArrayList<ItemStack> checked = new ArrayList<ItemStack>();
for (int i = 0; i < 9; i++) {
ItemStack contentAt = this.contents.getStackInSlot(i);
if (contentAt != null && contentAt.getMaxStackSize() > 1 &&
!containsItem(checked, contentAt)) {
if (contentAt != null && contentAt.getMaxStackSize() > 1
&& !containsItem(checked, contentAt)) {
checked.add(contentAt.copy());
int total = 0;
int stacks = 0;
@ -228,8 +252,9 @@ public class ContainerClipboard extends Container {
int[] iterator = { 0, 1, 2, 5, 8, 7, 6, 3 };
int freeSlots = 0;
for (int i : iterator) {
if (this.contents.getStackInSlot(i) != null && (this.contents.getStackInSlot(i)).stackSize > 1 && this.contents
.getStackInSlot(i).getMaxStackSize() > 1)
if (this.contents.getStackInSlot(i) != null
&& (this.contents.getStackInSlot(i)).stackSize > 1
&& this.contents.getStackInSlot(i).getMaxStackSize() > 1)
if (firstStack == null) {
firstStack = this.contents.getStackInSlot(i);
} else if (secondStack == null) {
@ -247,38 +272,58 @@ public class ContainerClipboard extends Container {
if (this.contents.getStackInSlot(i) == null)
if (turn) {
if (firstStack.stackSize > 1) {
this.contents.setInventorySlotContents(i, new ItemStack(firstStack.getItem(), 1, firstStack
.getItemDamage()));
this.contents.setInventorySlotContents(
i,
new ItemStack(
firstStack.getItem(), 1, firstStack.getItemDamage()
)
);
if (firstStack.hasTagCompound())
this.contents.getStackInSlot(i).setTagCompound((NBTTagCompound) firstStack
.getTagCompound().copy());
this.contents.getStackInSlot(i).setTagCompound(
(NBTTagCompound) firstStack.getTagCompound().copy()
);
firstStack.stackSize--;
hasChanged = true;
} else if (secondStack != null && secondStack.stackSize > 1) {
this.contents.setInventorySlotContents(i, new ItemStack(secondStack.getItem(), 1, secondStack
.getItemDamage()));
this.contents.setInventorySlotContents(
i,
new ItemStack(
secondStack.getItem(), 1, secondStack.getItemDamage()
)
);
if (secondStack.hasTagCompound())
this.contents.getStackInSlot(i).setTagCompound((NBTTagCompound)secondStack
.getTagCompound().copy());
this.contents.getStackInSlot(i).setTagCompound(
(NBTTagCompound) secondStack.getTagCompound().copy()
);
secondStack.stackSize--;
hasChanged = true;
}
turn = (secondStack == null);
} else {
if (secondStack.stackSize > 1) {
this.contents.setInventorySlotContents(i, new ItemStack(secondStack.getItem(), 1, secondStack
.getItemDamage()));
this.contents.setInventorySlotContents(
i,
new ItemStack(
secondStack.getItem(), 1, secondStack.getItemDamage()
)
);
if (secondStack.hasTagCompound())
this.contents.getStackInSlot(i).setTagCompound((NBTTagCompound)secondStack
.getTagCompound().copy());
this.contents.getStackInSlot(i).setTagCompound(
(NBTTagCompound) secondStack.getTagCompound().copy()
);
secondStack.stackSize--;
hasChanged = true;
} else if (firstStack != null && firstStack.stackSize > 1) {
this.contents.setInventorySlotContents(i, new ItemStack(firstStack.getItem(), 1, firstStack
.getItemDamage()));
this.contents.setInventorySlotContents(
i,
new ItemStack(
firstStack.getItem(), 1, firstStack.getItemDamage()
)
);
if (firstStack.hasTagCompound())
this.contents.getStackInSlot(i).setTagCompound((NBTTagCompound)firstStack
.getTagCompound().copy());
this.contents.getStackInSlot(i).setTagCompound(
(NBTTagCompound) firstStack.getTagCompound().copy()
);
firstStack.stackSize--;
hasChanged = true;
}
@ -309,10 +354,13 @@ public class ContainerClipboard extends Container {
private boolean areStacksSameItem(ItemStack stack1, ItemStack stack2) {
if (stack1 == null || stack2 == null)
return (stack1 == null && stack2 == null);
return (stack1.getItem() == stack2.getItem() && stack1.getItemDamage() == stack2
.getItemDamage() && ((stack1.hasTagCompound() && stack2.hasTagCompound() &&
ItemStack.areItemStackTagsEqual(stack1, stack2)) || (
!stack1.hasTagCompound() && !stack2.hasTagCompound())));
return (
stack1.getItem() == stack2.getItem()
&& stack1.getItemDamage() == stack2.getItemDamage()
&& ((stack1.hasTagCompound() && stack2.hasTagCompound()
&& ItemStack.areItemStackTagsEqual(stack1, stack2))
|| (!stack1.hasTagCompound() && !stack2.hasTagCompound()))
);
}
public void clearMatrix() {
@ -357,13 +405,15 @@ public class ContainerClipboard extends Container {
public void onSlotChanged() {
super.onSlotChanged();
if (getHasStack() && (getStack()).stackSize <= 0)
this.inventory.setInventorySlotContents(this.index, (ItemStack)null);
this.inventory.setInventorySlotContents(this.index, (ItemStack) null);
ContainerClipboard.this.save();
}
}
private class ClipSlotCrafting extends SlotCrafting {
public ClipSlotCrafting(EntityPlayer player, IInventory inv, IInventory inv2, int slot, int x, int y) {
public ClipSlotCrafting(
EntityPlayer player, IInventory inv, IInventory inv2, int slot, int x, int y
) {
super(player, inv, inv2, slot, x, y);
}
@ -380,7 +430,8 @@ public class ContainerClipboard extends Container {
return false;
int firstID = OreDictionary.getOreID(first);
if (firstID > 0) {
ArrayList<ItemStack> firstOres = OreDictionary.getOres(Integer.valueOf(firstID));
ArrayList<ItemStack> firstOres
= OreDictionary.getOres(Integer.valueOf(firstID));
if (firstOres != null && firstOres.size() > 0)
for (ItemStack tempStack : firstOres) {
if (OreDictionary.itemMatches(tempStack, second, false))
@ -389,5 +440,4 @@ public class ContainerClipboard extends Container {
}
return false;
}
}

View File

@ -21,13 +21,17 @@ public class ContainerForceEngine extends Container {
public ContainerForceEngine(EntityPlayer player, TileEntityForceEngine engine) {
this.user = player;
this.engine = engine;
this.playerInv = (IInventory)player.inventory;
addSlotToContainer(new FuelSlot((IInventory)engine.liquidInventory, 0, 38, 33));
addSlotToContainer(new ThrottleSlot((IInventory)engine.liquidInventory, 1, 122, 33));
this.playerInv = (IInventory) player.inventory;
addSlotToContainer(new FuelSlot((IInventory) engine.liquidInventory, 0, 38, 33));
addSlotToContainer(
new ThrottleSlot((IInventory) engine.liquidInventory, 1, 122, 33)
);
int i;
for (i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++)
addSlotToContainer(new Slot(this.playerInv, i * 9 + j + 9, 8 + 18 * j, 79 + 18 * i));
addSlotToContainer(
new Slot(this.playerInv, i * 9 + j + 9, 8 + 18 * j, 79 + 18 * i)
);
}
for (i = 0; i < 9; i++)
addSlotToContainer(new Slot(this.playerInv, i, 8 + 18 * i, 137));
@ -53,15 +57,17 @@ public class ContainerForceEngine extends Container {
if (!mergeItemStack(stack, 2, 38, true))
return null;
if (index >= 2)
if (ForceEngineLiquids.isFuel(FluidContainerRegistry.getFluidForFilledItem(stack)) || stack.getItem() == DartItems.forcegem) {
if (ForceEngineLiquids.isFuel(
FluidContainerRegistry.getFluidForFilledItem(stack)
)
|| stack.getItem() == DartItems.forcegem) {
if (!mergeItemStack(stack, 0, 1, false))
return null;
} else if (ForceEngineLiquids.isThrottle(FluidContainerRegistry.getFluidForFilledItem(stack)) &&
!mergeItemStack(stack, 1, 2, false)) {
} else if (ForceEngineLiquids.isThrottle(FluidContainerRegistry.getFluidForFilledItem(stack)) && !mergeItemStack(stack, 1, 2, false)) {
return null;
}
if (stack.stackSize == 0) {
slot.putStack((ItemStack)null);
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
@ -72,7 +78,8 @@ public class ContainerForceEngine extends Container {
return returnStack;
}
protected void retrySlotClick(int par1, int par2, boolean par3, EntityPlayer par4EntityPlayer) {}
protected void
retrySlotClick(int par1, int par2, boolean par3, EntityPlayer par4EntityPlayer) {}
public boolean canInteractWith(EntityPlayer player) {
return true;
@ -86,7 +93,9 @@ public class ContainerForceEngine extends Container {
public boolean isItemValid(ItemStack stack) {
if (stack.getItem() == DartItems.forcegem)
return true;
return ForceEngineLiquids.isFuel(FluidContainerRegistry.getFluidForFilledItem(stack));
return ForceEngineLiquids.isFuel(
FluidContainerRegistry.getFluidForFilledItem(stack)
);
}
}
@ -96,8 +105,9 @@ public class ContainerForceEngine extends Container {
}
public boolean isItemValid(ItemStack stack) {
return ForceEngineLiquids.isThrottle(FluidContainerRegistry.getFluidForFilledItem(stack));
return ForceEngineLiquids.isThrottle(
FluidContainerRegistry.getFluidForFilledItem(stack)
);
}
}
}

View File

@ -69,19 +69,22 @@ public class GuiClipboard extends GuiContainer {
if (this.balanceBounds.contains(pos)) {
getClass();
this.balanceRender = 8;
Dartcraft.proxy.sendPacketToServer((DartPacket) new PacketClipButton((EntityPlayer)((GuiScreen)this).mc.thePlayer, 0));
Dartcraft.proxy.sendPacketToServer((DartPacket
) new PacketClipButton((EntityPlayer) ((GuiScreen) this).mc.thePlayer, 0));
this.container.balanceItems();
}
if (this.distBounds.contains(pos)) {
getClass();
this.distRender = 8;
Dartcraft.proxy.sendPacketToServer((DartPacket)new PacketClipButton((EntityPlayer)((GuiScreen)this).mc.thePlayer, 1));
Dartcraft.proxy.sendPacketToServer((DartPacket
) new PacketClipButton((EntityPlayer) ((GuiScreen) this).mc.thePlayer, 1));
this.container.doDistribute();
}
if (this.clearBounds.contains(pos)) {
getClass();
this.clearRender = 8;
Dartcraft.proxy.sendPacketToServer((DartPacket)new PacketClipButton((EntityPlayer)((GuiScreen)this).mc.thePlayer, 2));
Dartcraft.proxy.sendPacketToServer((DartPacket
) new PacketClipButton((EntityPlayer) ((GuiScreen) this).mc.thePlayer, 2));
this.container.clearMatrix();
}
}
@ -95,11 +98,15 @@ public class GuiClipboard extends GuiContainer {
this.distRender--;
}
if (this.balanceRender > 0) {
drawTexturedModalRect(this.balanceBounds.x, this.balanceBounds.y, 176, 0, 11, 11);
drawTexturedModalRect(
this.balanceBounds.x, this.balanceBounds.y, 176, 0, 11, 11
);
this.balanceRender--;
}
if (this.clearRender > 0) {
drawTexturedModalRect(this.clearBounds.x, this.clearBounds.y, 176, 22, 11, 11);
drawTexturedModalRect(
this.clearBounds.x, this.clearBounds.y, 176, 22, 11, 11
);
this.clearRender--;
}
}
@ -116,13 +123,16 @@ public class GuiClipboard extends GuiContainer {
GL11.glColor4f(value, value, value, 0.65F);
GL11.glEnable(3042);
GL11.glDisable(2896);
itemRenderer.renderItemIntoGUI(this.fontRendererObj, ((GuiScreen)this).mc.renderEngine, stack, x, y, false);
itemRenderer.renderItemIntoGUI(
this.fontRendererObj, ((GuiScreen) this).mc.renderEngine, stack, x, y, false
);
GL11.glDisable(3042);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.zLevel = 0.0F;
}
public boolean handleDragNDrop(GuiContainer gui, int x, int y, ItemStack stack, int button) {
public boolean
handleDragNDrop(GuiContainer gui, int x, int y, ItemStack stack, int button) {
return false;
}
@ -134,4 +144,3 @@ public class GuiClipboard extends GuiContainer {
return null;
}
}

View File

@ -19,7 +19,6 @@ import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class GuiEngine extends GuiTab {
private TileEntityForceEngine engine;
@ -49,17 +48,24 @@ public class GuiEngine extends GuiTab {
this.throttleBounds = new Rectangle(this.guiLeft + 94, this.guiTop + 11, 16, 58);
}
public List<String> handleItemTooltip(ItemStack stack, int x, int y, List<String> tooltip) {
public List<String>
handleItemTooltip(ItemStack stack, int x, int y, List<String> tooltip) {
Point pointerLoc = new Point(x, y);
if (this.fuelBounds.contains(pointerLoc))
try {
tooltip.add("" + this.engine.fuelTank.getFluid().getFluid().getLocalizedName() + " (" + (this.engine.fuelTank.getFluid()).amount + ")");
tooltip.add(
"" + this.engine.fuelTank.getFluid().getFluid().getLocalizedName()
+ " (" + (this.engine.fuelTank.getFluid()).amount + ")"
);
} catch (Exception e) {
tooltip.add("Empty");
}
if (this.throttleBounds.contains(pointerLoc))
try {
tooltip.add("" + (this.engine.throttleTank.getInfo()).fluid.getFluid().getName() + " (" + (this.engine.throttleTank.getFluid()).amount + ")");
tooltip.add(
"" + (this.engine.throttleTank.getInfo()).fluid.getFluid().getName()
+ " (" + (this.engine.throttleTank.getFluid()).amount + ")"
);
} catch (Exception e) {
tooltip.add("Empty");
}
@ -73,10 +79,18 @@ public class GuiEngine extends GuiTab {
int posX = (this.width - this.xSize) / 2;
int posY = (this.height - this.ySize) / 2;
drawTexturedModalRect(posX, posY, 0, 0, this.xSize, this.ySize);
if (this.engine.fuelTank.getFluid() != null && (this.engine.fuelTank.getFluid()).amount > 0)
displayGauge(this.fuelBounds.x, this.fuelBounds.y, this.engine.fuelTank.getFluid());
if (this.engine.throttleTank.getFluid() != null && (this.engine.throttleTank.getFluid()).amount > 0)
displayGauge(this.throttleBounds.x, this.throttleBounds.y, this.engine.throttleTank.getFluid());
if (this.engine.fuelTank.getFluid() != null
&& (this.engine.fuelTank.getFluid()).amount > 0)
displayGauge(
this.fuelBounds.x, this.fuelBounds.y, this.engine.fuelTank.getFluid()
);
if (this.engine.throttleTank.getFluid() != null
&& (this.engine.throttleTank.getFluid()).amount > 0)
displayGauge(
this.throttleBounds.x,
this.throttleBounds.y,
this.engine.throttleTank.getFluid()
);
}
private void displayGauge(int x, int y, FluidStack liquid) {
@ -84,7 +98,7 @@ public class GuiEngine extends GuiTab {
if (liquid == null)
return;
int start = 0;
int squaled = (int)(58.0F * liquid.amount / 10000.0F);
int squaled = (int) (58.0F * liquid.amount / 10000.0F);
Dartcraft.proxy.bindTexture("textures/atlas/blocks.png");
do {
tempx = 0;
@ -98,7 +112,9 @@ public class GuiEngine extends GuiTab {
IIcon icon = liquid.getFluid().getStillIcon();
if (icon == null)
icon = FluidRegistry.LAVA.getStillIcon();
drawTexturedModelRectFromIcon(x, y + 58 - tempx - start, icon, 16, 16 - 16 - tempx);
drawTexturedModelRectFromIcon(
x, y + 58 - tempx - start, icon, 16, 16 - 16 - tempx
);
start += 16;
} while (tempx != 0 && squaled != 0);
Dartcraft.proxy.bindTexture("engineGui.png");
@ -124,7 +140,9 @@ public class GuiEngine extends GuiTab {
float output = GuiEngine.this.engine.getEnergyPerProcess();
float throttle = 0.0F;
if (GuiEngine.this.engine.throttleTank.getFluid() != null) {
EngineLiquid throttleLiquid = ForceEngineLiquids.getEngineLiquid(GuiEngine.this.engine.throttleTank.getFluid());
EngineLiquid throttleLiquid = ForceEngineLiquids.getEngineLiquid(
GuiEngine.this.engine.throttleTank.getFluid()
);
if (throttleLiquid != null)
throttle = throttleLiquid.getModifier();
}
@ -134,15 +152,28 @@ public class GuiEngine extends GuiTab {
Tab.tabFontRenderer.drawStringWithShadow("Output", x + 22, y + 6, 16777215);
Tab.tabFontRenderer.drawStringWithShadow("MJ/t:", x + 8, y + 20, 16777215);
if (output > 0.0F) {
Tab.tabFontRenderer.drawStringWithShadow("" + GuiEngine.this.engine.getEnergyPerProcess(), x + 36, y + 20, subColor);
Tab.tabFontRenderer.drawStringWithShadow(
"" + GuiEngine.this.engine.getEnergyPerProcess(),
x + 36,
y + 20,
subColor
);
} else {
Tab.tabFontRenderer.drawStringWithShadow("None", x + 36, y + 20, subColor);
Tab.tabFontRenderer.drawStringWithShadow(
"None", x + 36, y + 20, subColor
);
}
Tab.tabFontRenderer.drawStringWithShadow("Throttle:", x + 8, y + 30, 16777215);
Tab.tabFontRenderer.drawStringWithShadow(
"Throttle:", x + 8, y + 30, 16777215
);
if (throttle > 0.0F) {
Tab.tabFontRenderer.drawStringWithShadow("" + throttle, x + 55, y + 30, subColor);
Tab.tabFontRenderer.drawStringWithShadow(
"" + throttle, x + 55, y + 30, subColor
);
} else {
Tab.tabFontRenderer.drawStringWithShadow("None", x + 55, y + 30, subColor);
Tab.tabFontRenderer.drawStringWithShadow(
"None", x + 55, y + 30, subColor
);
}
}
@ -170,19 +201,35 @@ public class GuiEngine extends GuiTab {
}
private void initializeItems() {
this.infoStrings.add("The Force Engine can be throttled with a few liquids, most notably water.");
this.infoStrings.add("The Force Engine's output is determined by the base output of the Fuel multiplied by the Throttle's value.");
this.infoStrings.add("The Force Engine will never explode or die of loneliness.");
this.infoStrings.add(
"The Force Engine can be throttled with a few liquids, most notably water."
);
this.infoStrings.add(
"The Force Engine's output is determined by the base output of the Fuel multiplied by the Throttle's value."
);
this.infoStrings.add(
"The Force Engine will never explode or die of loneliness."
);
this.infoStrings.add("The Force Engine requires a redstone signal to run.");
this.infoStrings.add("You can right-click the Force Engine with a valid liquid container to add liquid quickly.");
this.infoStrings.add(
"You can right-click the Force Engine with a valid liquid container to add liquid quickly."
);
if (Loader.isModLoaded("BuildCraft|Energy")) {
this.infoStrings.add("A wide variety of fuels are usable inside the Force Engine. While Liquid Force is the most effective, BuildCraft Fuel or even lava is also usable.");
this.infoStrings.add("Using Fuel or Lava in the Force Engine will yield the same output as the Combustion Engine if water is used as a throttle.");
this.infoStrings.add(
"A wide variety of fuels are usable inside the Force Engine. While Liquid Force is the most effective, BuildCraft Fuel or even lava is also usable."
);
this.infoStrings.add(
"Using Fuel or Lava in the Force Engine will yield the same output as the Combustion Engine if water is used as a throttle."
);
} else {
this.infoStrings.add("Lava is also a valid Force Engine Fuel, although not as effective as Liquid Force.");
this.infoStrings.add(
"Lava is also a valid Force Engine Fuel, although not as effective as Liquid Force."
);
}
if (Loader.isModLoaded("Forestry")) {
this.infoStrings.add("Liquid Force may also be obtained by squeezing Force Logs.");
this.infoStrings.add(
"Liquid Force may also be obtained by squeezing Force Logs."
);
this.infoStrings.add("Milk is also an effective throttle.");
this.infoStrings.add("Did someone say Glacial bees?");
}
@ -207,8 +254,12 @@ public class GuiEngine extends GuiTab {
drawIcon("items.png", 0, x + 2, y + 2);
if (!isFullyOpened())
return;
Tab.tabFontRenderer.drawStringWithShadow("Information", x + 22, y + 6, 16777215);
Tab.tabFontRenderer.drawSplitString(this.currentInfo, x + 8, y + 20, this.maxWidth - 14, 0);
Tab.tabFontRenderer.drawStringWithShadow(
"Information", x + 22, y + 6, 16777215
);
Tab.tabFontRenderer.drawSplitString(
this.currentInfo, x + 8, y + 20, this.maxWidth - 14, 0
);
}
private String getRandomItem() {

View File

@ -13,20 +13,22 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class GuiHandler implements IGuiHandler {
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
public Object
getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
ItemStack clipStack;
switch (ID) {
case 0:
clipStack = getClipboard(player);
if (clipStack != null)
return new ContainerClipboard(player, new ItemCraftingInventory(9, clipStack));
return new ContainerClipboard(
player, new ItemCraftingInventory(9, clipStack)
);
break;
case 7:
TileEntity te2 = world.getTileEntity(x, y, z);
if (te2 != null && te2 instanceof TileEntityForceEngine) {
TileEntityForceEngine engine = (TileEntityForceEngine)te2;
TileEntityForceEngine engine = (TileEntityForceEngine) te2;
return new ContainerForceEngine(player, engine);
}
break;
@ -35,18 +37,21 @@ public class GuiHandler implements IGuiHandler {
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
public Object
getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
ItemStack clipStack;
switch (ID) {
case 0:
clipStack = getClipboard(player);
if (clipStack != null)
return new GuiClipboard(new ContainerClipboard(player, new ItemCraftingInventory(9, clipStack)));
return new GuiClipboard(new ContainerClipboard(
player, new ItemCraftingInventory(9, clipStack)
));
break;
case 7:
TileEntity te2 = world.getTileEntity(x, y, z);
if (te2 instanceof TileEntityForceEngine) {
TileEntityForceEngine engine = (TileEntityForceEngine)te2;
TileEntityForceEngine engine = (TileEntityForceEngine) te2;
return new GuiEngine(new ContainerForceEngine(player, engine));
}
break;
@ -60,12 +65,14 @@ public class GuiHandler implements IGuiHandler {
if (dartTag != null)
for (int i = 0; i < 9; i++) {
ItemStack tempStack = player.inventory.mainInventory[i];
if (tempStack != null && tempStack.getItem() instanceof ItemClipboard && tempStack
.getTagCompound().getInteger("ID") == dartTag.getInteger("toOpen"))
if (tempStack != null && tempStack.getItem() instanceof ItemClipboard
&& tempStack.getTagCompound().getInteger("ID")
== dartTag.getInteger("toOpen"))
if (location == -1) {
location = i;
} else {
player.inventory.mainInventory[i].getTagCompound().removeTag("ID");
player.inventory.mainInventory[i].getTagCompound().removeTag("ID"
);
dartTag.removeTag("toOpen");
return null;
}
@ -75,5 +82,4 @@ public class GuiHandler implements IGuiHandler {
return player.inventory.mainInventory[location];
return null;
}
}

View File

@ -11,16 +11,25 @@ import java.util.ArrayList;
public abstract class GuiTab extends GuiContainer {
protected enum SlotColor {
BLUE, RED, YELLOW, ORANGE, GREEN, PURPLE;
BLUE,
RED,
YELLOW,
ORANGE,
GREEN,
PURPLE;
}
protected enum SlotType {
//SINGLE, OUTPUT, DOUBLEOUTPUT;
TOP, BOTTOM, FULL
TOP,
BOTTOM,
FULL
}
protected enum SlotRender {
TOP, BOTTOM, FULL;
TOP,
BOTTOM,
FULL;
}
protected static int SCALE_ENERGY = 42;
@ -60,7 +69,8 @@ public abstract class GuiTab extends GuiContainer {
protected abstract void drawTooltips();
protected void drawColoredSlot(int x, int y, SlotColor color, SlotType type, SlotRender render) {
protected void
drawColoredSlot(int x, int y, SlotColor color, SlotType type, SlotRender render) {
if (enableGuiBorders) {
drawColoredSlotWithBorder(x, y, color, type, render);
} else {
@ -68,7 +78,9 @@ public abstract class GuiTab extends GuiContainer {
}
}
protected void drawColoredSlotNoBorder(int x, int y, SlotColor color, SlotType type, SlotRender render) {
protected void drawColoredSlotNoBorder(
int x, int y, SlotColor color, SlotType type, SlotRender render
) {
int sizeX = 0;
int sizeY = 0;
int offsetX = color.ordinal() / 3 * 128;
@ -106,7 +118,9 @@ public abstract class GuiTab extends GuiContainer {
drawTexturedModalRect(x, y, offsetX, offsetY, sizeX, sizeY);
}
protected void drawColoredSlotWithBorder(int x, int y, SlotColor color, SlotType type, SlotRender render) {
protected void drawColoredSlotWithBorder(
int x, int y, SlotColor color, SlotType type, SlotRender render
) {
int sizeX = 32;
int sizeY = 32;
int offsetX = color.ordinal() / 3 * 128;
@ -165,7 +179,8 @@ public abstract class GuiTab extends GuiContainer {
drawTexturedModalRect(x - 8, y - 2, offsetX, offsetY, sizeX, sizeY);
}
protected void drawLiquid(int j, int k, int liquidId, NBTTagCompound comp, int width, int height) {
protected void
drawLiquid(int j, int k, int liquidId, NBTTagCompound comp, int width, int height) {
int liquidImgIndex = 0;
try {
FluidStack tempStack = new FluidStack(liquidId, 0, comp);
@ -183,7 +198,9 @@ public abstract class GuiTab extends GuiContainer {
for (y = 0; y < height; y += 16) {
drawWidth = Math.min(width - x, 16);
drawHeight = Math.min(height - y, 16);
drawTexturedModalRect(j + x, k + y, imgColumn * 16, imgLine * 16, drawWidth, drawHeight);
drawTexturedModalRect(
j + x, k + y, imgColumn * 16, imgLine * 16, drawWidth, drawHeight
);
}
}
}
@ -203,7 +220,8 @@ public abstract class GuiTab extends GuiContainer {
protected void mouseClicked(int x, int y, int mouseButton) {
super.mouseClicked(x, y, mouseButton);
Tab tab = getTabAtPosition(this.mouseX, this.mouseY);
if (tab != null && !tab.handleMouseClicked(this.mouseX, this.mouseY, mouseButton)) {
if (tab != null
&& !tab.handleMouseClicked(this.mouseX, this.mouseY, mouseButton)) {
if (tab.leftSide) {
for (Tab other : this.tabListLeft) {
if (other != tab && other.isOpen())
@ -221,7 +239,7 @@ public abstract class GuiTab extends GuiContainer {
public void handleMouseInput() {
int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
int y = this.height- Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
this.mouseX = x - (this.width - this.xSize) / 2;
this.mouseY = y - (this.height - this.ySize) / 2;
super.handleMouseInput();
@ -230,11 +248,13 @@ public abstract class GuiTab extends GuiContainer {
public void addTab(Tab tab) {
if (tab.leftSide) {
this.tabListLeft.add(tab);
if (TabVars.getOpenedLeftTab() != null && tab.getClass().equals(TabVars.getOpenedLeftTab()))
if (TabVars.getOpenedLeftTab() != null
&& tab.getClass().equals(TabVars.getOpenedLeftTab()))
tab.setFullyOpen();
} else {
this.tabListRight.add(tab);
if (TabVars.getOpenedRightTab() != null && tab.getClass().equals(TabVars.getOpenedRightTab()))
if (TabVars.getOpenedRightTab() != null
&& tab.getClass().equals(TabVars.getOpenedRightTab()))
tab.setFullyOpen();
}
}

View File

@ -7,7 +7,8 @@ import net.minecraft.client.gui.Gui;
import org.lwjgl.opengl.GL11;
public abstract class Tab {
protected static FontRenderer tabFontRenderer = (FMLClientHandler.instance().getClient()).fontRenderer;
protected static FontRenderer tabFontRenderer
= (FMLClientHandler.instance().getClient()).fontRenderer;
private boolean open;
@ -48,16 +49,48 @@ public abstract class Tab {
GL11.glColor4f(colorR, colorG, colorB, 1.0F);
if (this.leftSide) {
Dartcraft.proxy.bindTexture("tab_left.png");
this.myGui.drawTexturedModalRect(x - this.currentWidth, y + 4, 0, 256 - this.currentHeight + 4, 4, this.currentHeight - 4);
this.myGui.drawTexturedModalRect(x - this.currentWidth + 4, y, 256 - this.currentWidth + 4, 0, this.currentWidth - 4, 4);
this.myGui.drawTexturedModalRect(
x - this.currentWidth,
y + 4,
0,
256 - this.currentHeight + 4,
4,
this.currentHeight - 4
);
this.myGui.drawTexturedModalRect(
x - this.currentWidth + 4,
y,
256 - this.currentWidth + 4,
0,
this.currentWidth - 4,
4
);
this.myGui.drawTexturedModalRect(x - this.currentWidth, y, 0, 0, 4, 4);
this.myGui.drawTexturedModalRect(x - this.currentWidth + 4, y + 4, 256 - this.currentWidth + 4, 256 - this.currentHeight + 4, this.currentWidth - 4, this.currentHeight - 4);
this.myGui.drawTexturedModalRect(
x - this.currentWidth + 4,
y + 4,
256 - this.currentWidth + 4,
256 - this.currentHeight + 4,
this.currentWidth - 4,
this.currentHeight - 4
);
} else {
Dartcraft.proxy.bindTexture("tab_right.png");
this.myGui.drawTexturedModalRect(x, y, 0, 256 - this.currentHeight, 4, this.currentHeight);
this.myGui.drawTexturedModalRect(x + 4, y, 256 - this.currentWidth + 4, 0, this.currentWidth - 4, 4);
this.myGui.drawTexturedModalRect(
x, y, 0, 256 - this.currentHeight, 4, this.currentHeight
);
this.myGui.drawTexturedModalRect(
x + 4, y, 256 - this.currentWidth + 4, 0, this.currentWidth - 4, 4
);
this.myGui.drawTexturedModalRect(x, y, 0, 0, 4, 4);
this.myGui.drawTexturedModalRect(x + 4, y + 4, 256 - this.currentWidth + 4, 256 - this.currentHeight + 4, this.currentWidth - 4, this.currentHeight - 4);
this.myGui.drawTexturedModalRect(
x + 4,
y + 4,
256 - this.currentWidth + 4,
256 - this.currentHeight + 4,
this.currentWidth - 4,
this.currentHeight - 4
);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
@ -67,7 +100,9 @@ public abstract class Tab {
Dartcraft.proxy.bindTexture(texture);
int textureRow = iconIndex >> 4;
int textureColumn = iconIndex - 16 * textureRow;
this.myGui.drawTexturedModalRect(x, y, 16 * textureColumn, 16 * textureRow, 16, 16);
this.myGui.drawTexturedModalRect(
x, y, 16 * textureColumn, 16 * textureRow, 16, 16
);
}
public int getHeight() {
@ -82,7 +117,8 @@ public abstract class Tab {
public boolean intersectsWith(int mouseX, int mouseY, int shiftX, int shiftY) {
if (this.leftSide) {
if (mouseX <= shiftX && mouseX >= shiftX - this.currentWidth && mouseY >= shiftY && mouseY <= shiftY + this.currentHeight)
if (mouseX <= shiftX && mouseX >= shiftX - this.currentWidth
&& mouseY >= shiftY && mouseY <= shiftY + this.currentHeight)
return true;
} else if (mouseX >= shiftX && mouseX <= shiftX + this.currentWidth && mouseY >= shiftY && mouseY <= shiftY + this.currentHeight) {
return true;

View File

@ -9,7 +9,6 @@ import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
public class BlockRenderer {
protected static float W1 = 0.0625F;
protected static float W2 = 0.125F;
@ -38,11 +37,22 @@ public class BlockRenderer {
protected static float W15 = 0.9375F;
public static void DrawFaces(RenderBlocks renderblocks, Block block, IIcon i, boolean st) {
public static void
DrawFaces(RenderBlocks renderblocks, Block block, IIcon i, boolean st) {
DrawFaces(renderblocks, block, i, i, i, i, i, i, st);
}
public static void DrawFaces(RenderBlocks renderblocks, Block block, IIcon i1, IIcon i2, IIcon i3, IIcon i4, IIcon i5, IIcon i6, boolean solidtop) {
public static void DrawFaces(
RenderBlocks renderblocks,
Block block,
IIcon i1,
IIcon i2,
IIcon i3,
IIcon i4,
IIcon i5,
IIcon i6,
boolean solidtop
) {
Tessellator tessellator = Tessellator.instance;
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
tessellator.startDrawingQuads();
@ -76,7 +86,8 @@ public class BlockRenderer {
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
public static int setBrightness(IBlockAccess blockAccess, int i, int j, int k, Block block) {
public static int
setBrightness(IBlockAccess blockAccess, int i, int j, int k, Block block) {
Tessellator tessellator = Tessellator.instance;
int mb = block.getMixedBrightnessForBlock(blockAccess, i, j, k);
tessellator.setBrightness(mb);
@ -97,11 +108,28 @@ public class BlockRenderer {
return mb;
}
protected static void renderAllSides(IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer, IIcon tex) {
protected static void renderAllSides(
IBlockAccess world,
int x,
int y,
int z,
Block block,
RenderBlocks renderer,
IIcon tex
) {
renderAllSides(world, x, y, z, block, renderer, tex, true);
}
public static void renderAllSides(IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer, IIcon tex, boolean allsides) {
public static void renderAllSides(
IBlockAccess world,
int x,
int y,
int z,
Block block,
RenderBlocks renderer,
IIcon tex,
boolean allsides
) {
if (allsides || block.shouldSideBeRendered(world, x + 1, y, z, 6))
renderer.renderFaceXPos(block, x, y, z, tex);
if (allsides || block.shouldSideBeRendered(world, x - 1, y, z, 6))
@ -116,7 +144,16 @@ public class BlockRenderer {
renderer.renderFaceYNeg(block, x, y, z, tex);
}
protected static void renderAllSidesInverted(IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer, IIcon tex, boolean allsides) {
protected static void renderAllSidesInverted(
IBlockAccess world,
int x,
int y,
int z,
Block block,
RenderBlocks renderer,
IIcon tex,
boolean allsides
) {
if (allsides || !block.shouldSideBeRendered(world, x - 1, y, z, 6))
renderer.renderFaceXPos(block, (x - 1), y, z, tex);
if (allsides || !block.shouldSideBeRendered(world, x + 1, y, z, 6))
@ -130,5 +167,4 @@ public class BlockRenderer {
if (allsides || !block.shouldSideBeRendered(world, x, y + 1, z, 6))
renderer.renderFaceYNeg(block, x, (y + 1), z, tex);
}
}

View File

@ -10,9 +10,10 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
public class PowerOreRenderer extends BlockRenderer implements ISimpleBlockRenderingHandler {
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
public class PowerOreRenderer
extends BlockRenderer implements ISimpleBlockRenderingHandler {
public void
renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
renderer.setRenderBoundsFromBlock(block);
IIcon bgIcon = null;
@ -28,7 +29,15 @@ public class PowerOreRenderer extends BlockRenderer implements ISimpleBlockRende
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
public boolean renderWorldBlock(
IBlockAccess world,
int x,
int y,
int z,
Block block,
int modelId,
RenderBlocks renderer
) {
int brightness = setBrightness(world, x, y, z, block);
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
renderer.setRenderBoundsFromBlock(block);

View File

@ -24,17 +24,26 @@ public class RenderTileForceEngine extends TileEntitySpecialRenderer {
static double[][] translate = new double[6][3];
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) {
public void
renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) {
TileEntityForceEngine engine;
if (tile instanceof TileEntityForceEngine) {
engine = (TileEntityForceEngine)tile;
engine = (TileEntityForceEngine) tile;
} else {
return;
}
render(engine.isActive, engine.getCycleProgress(), engine.getFacing().ordinal(), x, y, z);
render(
engine.isActive,
engine.getCycleProgress(),
engine.getFacing().ordinal(),
x,
y,
z
);
}
public void render(boolean active, float progress, int facing, double x, double y, double z) {
public void
render(boolean active, float progress, int facing, double x, double y, double z) {
float step;
GL11.glPushMatrix();
GL11.glTranslated(x, y, z);
@ -58,7 +67,11 @@ public class RenderTileForceEngine extends TileEntitySpecialRenderer {
Dartcraft.proxy.bindTexture("forceEngine.png");
base.render(0.0625F);
GL11.glPushMatrix();
GL11.glTranslated(translate[facing][0] * translateFactor, translate[facing][1] * translateFactor, translate[facing][2] * translateFactor);
GL11.glTranslated(
translate[facing][0] * translateFactor,
translate[facing][1] * translateFactor,
translate[facing][2] * translateFactor
);
piston.render(0.0625F);
GL11.glPopMatrix();
if (active) {
@ -75,7 +88,11 @@ public class RenderTileForceEngine extends TileEntitySpecialRenderer {
float extensionFactor = 0.125F;
for (int i = 0; i < step + 2.0F; i += 2) {
extension.render(0.0625F);
GL11.glTranslated(translate[facing][0] * extensionFactor, translate[facing][1] * extensionFactor, translate[facing][2] * extensionFactor);
GL11.glTranslated(
translate[facing][0] * extensionFactor,
translate[facing][1] * extensionFactor,
translate[facing][2] * extensionFactor
);
}
GL11.glPopMatrix();
}

View File

@ -9,7 +9,7 @@ import net.minecraft.util.ResourceLocation;
@SideOnly(Side.CLIENT)
public class RenderColdAnimal extends RenderLiving {
private final ResourceLocation texture;
private final ResourceLocation texture;
public RenderColdAnimal(ModelBase par1ModelBase, float par2, String textureLocation) {
super(par1ModelBase, par2);

View File

@ -16,23 +16,29 @@ import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderEntityBottle extends RenderLiving {
private static final ResourceLocation texture
= new ResourceLocation(Dartcraft.MODID, "bottle.png");
private static final ResourceLocation texture = new ResourceLocation(Dartcraft.MODID, "bottle.png");
private static IModelCustom bottle = AdvancedModelLoader.loadModel(new ResourceLocation(Dartcraft.MODID, "models/bottle.obj"));
private static IModelCustom bottle = AdvancedModelLoader.loadModel(
new ResourceLocation(Dartcraft.MODID, "models/bottle.obj")
);
public RenderEntityBottle() {
super(null, 0.2F);
}
@Override
public void doRender(Entity entity, double par2, double par4, double par6, float par8, float par9) {
public void doRender(
Entity entity, double par2, double par4, double par6, float par8, float par9
) {
if (entity instanceof IBottleRenderable) {
ItemStack stack = ((IBottleRenderable)entity).getEntityItem();
ItemStack stack = ((IBottleRenderable) entity).getEntityItem();
GL11.glPushMatrix();
GL11.glTranslated(par2, par4 + 0.25D, par6);
GL11.glScalef(0.5F, 0.5F, 0.5F);
RenderItemForceFlask.instance.renderItem(IItemRenderer.ItemRenderType.ENTITY, stack, new Object[0]);
RenderItemForceFlask.instance.renderItem(
IItemRenderer.ItemRenderType.ENTITY, stack, new Object[0]
);
GL11.glPopMatrix();
}
}
@ -40,5 +46,4 @@ public class RenderEntityBottle extends RenderLiving {
protected ResourceLocation getEntityTexture(Entity entity) {
return texture;
}
}

View File

@ -9,12 +9,18 @@ public class RenderItemEngine implements IItemRenderer {
return true;
}
public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) {
public boolean shouldUseRenderHelper(
IItemRenderer.ItemRenderType type,
ItemStack item,
IItemRenderer.ItemRendererHelper helper
) {
return true;
}
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
if (type == IItemRenderer.ItemRenderType.EQUIPPED || type == IItemRenderer.ItemRenderType.INVENTORY) {
public void
renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
if (type == IItemRenderer.ItemRenderType.EQUIPPED
|| type == IItemRenderer.ItemRenderType.INVENTORY) {
ClientProxy.engineRender.render(false, 0.25F, 1, 0.0D, 0.0D, 0.0D);
} else {
ClientProxy.engineRender.render(false, 0.25F, 1, -0.5D, -0.5D, -0.5D);

View File

@ -30,12 +30,15 @@ import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderItemForceFlask implements IItemRenderer {
private static RenderItem renderer = new RenderItem();
private IModelCustom bottle = AdvancedModelLoader.loadModel(new ResourceLocation(Dartcraft.MODID, "models/bottle.obj"));
private IModelCustom bottle = AdvancedModelLoader.loadModel(
new ResourceLocation(Dartcraft.MODID, "models/bottle.obj")
);
private IModelCustom liquid = AdvancedModelLoader.loadModel(new ResourceLocation(Dartcraft.MODID, "models/liquid.obj"));
private IModelCustom liquid = AdvancedModelLoader.loadModel(
new ResourceLocation(Dartcraft.MODID, "models/liquid.obj")
);
public static RenderItemForceFlask instance = new RenderItemForceFlask();
@ -43,34 +46,52 @@ public class RenderItemForceFlask implements IItemRenderer {
return true;
}
public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) {
return (type == IItemRenderer.ItemRenderType.INVENTORY || type == IItemRenderer.ItemRenderType.ENTITY);
public boolean shouldUseRenderHelper(
IItemRenderer.ItemRenderType type,
ItemStack item,
IItemRenderer.ItemRendererHelper helper
) {
return (
type == IItemRenderer.ItemRenderType.INVENTORY
|| type == IItemRenderer.ItemRenderType.ENTITY
);
}
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
public void
renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
FontRenderer fontRenderer = (Minecraft.getMinecraft()).fontRenderer;
Entity entity = null;
GL11.glPushMatrix();
if (item != null && item.getItem() instanceof ItemEntityBottle && item.hasTagCompound())
if (item != null && item.getItem() instanceof ItemEntityBottle
&& item.hasTagCompound())
try {
if (item.getItemDamage() == 0) {
EntityLivingBase entityLivingBase = null;
NBTTagCompound comp = (NBTTagCompound)item.getTagCompound().copy();
NBTTagCompound comp = (NBTTagCompound) item.getTagCompound().copy();
Entity temp = null;
if (comp.hasKey("CanPickUpLoot")) {
temp = EntityList.createEntityFromNBT(comp, (World)(Minecraft.getMinecraft()).theWorld);
temp = EntityList.createEntityFromNBT(
comp, (World) (Minecraft.getMinecraft()).theWorld
);
} else {
temp = EntityUtils.getEntity(comp.getString("id"));
}
if (temp instanceof EntityLivingBase)
entityLivingBase = (EntityLivingBase)temp;
if (entityLivingBase != null && (Dartcraft.proxy.getClientInstance()).theWorld != null) {
entityLivingBase.setWorld((World)(Dartcraft.proxy.getClientInstance()).theWorld);
entityLivingBase.setLocationAndAngles(0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
entityLivingBase = (EntityLivingBase) temp;
if (entityLivingBase != null
&& (Dartcraft.proxy.getClientInstance()).theWorld != null) {
entityLivingBase.setWorld(
(World) (Dartcraft.proxy.getClientInstance()).theWorld
);
entityLivingBase.setLocationAndAngles(
0.0D, 0.0D, 0.0D, 0.0F, 0.0F
);
}
entity = entityLivingBase;
} else if (item.getItemDamage() == 1) {
EntityItem entityItem = new EntityItem((World)(Dartcraft.proxy.getClientInstance()).theWorld);
EntityItem entityItem = new EntityItem(
(World) (Dartcraft.proxy.getClientInstance()).theWorld
);
entityItem.setLocationAndAngles(0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
entityItem.hoverStart = 1.0F;
entityItem.setEntityItemStack(new ItemStack(Blocks.brick_block));
@ -81,17 +102,25 @@ public class RenderItemForceFlask implements IItemRenderer {
float angle = 0.0F;
float scale = 0.0F;
scale(type);
if (type == IItemRenderer.ItemRenderType.INVENTORY && (entity instanceof net.minecraft.entity.monster.EntityEnderman || entity instanceof net.minecraft.entity.monster.EntitySpider || entity instanceof net.minecraft.entity.monster.EntityCaveSpider))
if (type == IItemRenderer.ItemRenderType.INVENTORY
&& (entity instanceof net.minecraft.entity.monster.EntityEnderman
|| entity instanceof net.minecraft.entity.monster.EntitySpider
|| entity instanceof net.minecraft.entity.monster.EntityCaveSpider))
entity = null;
if (entity != null) {
float coef = 1.0F;
if (entity instanceof net.minecraft.entity.monster.EntitySilverfish || entity instanceof net.minecraft.entity.passive.EntityOcelot || entity instanceof net.minecraft.entity.passive.EntityWolf)
if (entity instanceof net.minecraft.entity.monster.EntitySilverfish
|| entity instanceof net.minecraft.entity.passive.EntityOcelot
|| entity instanceof net.minecraft.entity.passive.EntityWolf)
coef = 2.5F;
scale = 8.0F * ((((Entity)entity).height > ((Entity)entity).width * coef) ? (1.3F / ((Entity)entity).height) : (0.5F / ((Entity)entity).width));
value = -((Entity)entity).height;
scale = 8.0F
* ((((Entity) entity).height > ((Entity) entity).width * coef)
? (1.3F / ((Entity) entity).height)
: (0.5F / ((Entity) entity).width));
value = -((Entity) entity).height;
angle = 0.0F;
if (entity instanceof net.minecraft.entity.passive.EntityPig)
scale = 6.5F / ((Entity)entity).height;
scale = 6.5F / ((Entity) entity).height;
if (entity instanceof EntityBottle) {
scale = 30.0F;
value += 1.5F;
@ -100,7 +129,7 @@ public class RenderItemForceFlask implements IItemRenderer {
int age = item.getTagCompound().getInteger("Age");
if (age < 0) {
scale /= 2.0F;
value -= ((Entity)entity).height * 0.5F;
value -= ((Entity) entity).height * 0.5F;
}
}
if (type == IItemRenderer.ItemRenderType.INVENTORY)
@ -115,11 +144,16 @@ public class RenderItemForceFlask implements IItemRenderer {
boolean shouldRender = (type != IItemRenderer.ItemRenderType.INVENTORY);
if (!shouldRender) {
Minecraft mc = Dartcraft.proxy.getClientInstance();
EntityClientPlayerMP entityClientPlayerMP = (mc != null) ? mc.thePlayer : null;
EntityClientPlayerMP entityClientPlayerMP
= (mc != null) ? mc.thePlayer : null;
boolean found = false;
if (entityClientPlayerMP != null && ((EntityPlayer)entityClientPlayerMP).inventory != null && ((EntityPlayer)entityClientPlayerMP).inventory.mainInventory != null)
if (entityClientPlayerMP != null
&& ((EntityPlayer) entityClientPlayerMP).inventory != null
&& ((EntityPlayer) entityClientPlayerMP).inventory.mainInventory
!= null)
for (int i = 0; i < 9; i++) {
ItemStack invStack = ((EntityPlayer)entityClientPlayerMP).inventory.mainInventory[i];
ItemStack invStack = ((EntityPlayer) entityClientPlayerMP)
.inventory.mainInventory[i];
if (invStack != null && invStack == item) {
found = true;
break;
@ -129,9 +163,10 @@ public class RenderItemForceFlask implements IItemRenderer {
shouldRender = true;
}
if (shouldRender) {
Render render = RenderManager.instance.getEntityRenderObject((Entity)entity);
Render render
= RenderManager.instance.getEntityRenderObject((Entity) entity);
if (render != null && entity != null)
render.doRender((Entity)entity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
render.doRender((Entity) entity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
}
} catch (Exception e) {}
GL11.glPopMatrix();
@ -193,10 +228,12 @@ public class RenderItemForceFlask implements IItemRenderer {
float angle = 0.0F;
float angle2 = 0.0F;
float scale = 0.0F;
value = ((Entity)(Minecraft.getMinecraft()).thePlayer).rotationYaw * 2.0F;
angle = ((Entity)(Minecraft.getMinecraft()).thePlayer).rotationPitch * 2.0F;
angle2 = ((EntityLivingBase)(Minecraft.getMinecraft()).thePlayer).rotationYawHead * 2.0F;
if (Keyboard.isKeyDown(50));
value = ((Entity) (Minecraft.getMinecraft()).thePlayer).rotationYaw * 2.0F;
angle = ((Entity) (Minecraft.getMinecraft()).thePlayer).rotationPitch * 2.0F;
angle2 = ((EntityLivingBase) (Minecraft.getMinecraft()).thePlayer).rotationYawHead
* 2.0F;
if (Keyboard.isKeyDown(50))
;
if (type == IItemRenderer.ItemRenderType.INVENTORY) {
scale = 0.04557239F;
GL11.glScalef(scale, scale, scale);
@ -226,5 +263,4 @@ public class RenderItemForceFlask implements IItemRenderer {
GL11.glScalef(scale, scale, scale);
}
}
}

View File

@ -19,7 +19,6 @@ import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class EntityBottle extends EntityLivingBase implements IBottleRenderable {
private int timeout;
public EntityBottle(World world) {
@ -35,21 +34,26 @@ public class EntityBottle extends EntityLivingBase implements IBottleRenderable
protected void entityInit() {
super.entityInit();
((Entity)this).getDataWatcher().addObject(12, new ItemStack(DartItems.entitybottle));
((Entity) this)
.getDataWatcher()
.addObject(12, new ItemStack(DartItems.entitybottle));
}
public void writeToNBT(NBTTagCompound comp) {
super.writeToNBT(comp);
ItemStack contents = getEntityItem();
if (contents != null)
comp.setTag("bottleContents", (NBTBase)contents.writeToNBT(new NBTTagCompound()));
comp.setTag(
"bottleContents", (NBTBase) contents.writeToNBT(new NBTTagCompound())
);
}
public void readFromNBT(NBTTagCompound comp) {
super.readFromNBT(comp);
if (comp.hasKey("bottleContents"))
setEntityItem(ItemStack.loadItemStackFromNBT(comp
.getCompoundTag("bottleContents")));
setEntityItem(
ItemStack.loadItemStackFromNBT(comp.getCompoundTag("bottleContents"))
);
}
public void writeEntityToNBT(NBTTagCompound comp) {}
@ -59,28 +63,34 @@ public class EntityBottle extends EntityLivingBase implements IBottleRenderable
public void onLivingUpdate() {
super.onLivingUpdate();
this.timeout--;
if (!Dartcraft.proxy.isSimulating(((Entity)this).worldObj)) {
if (!Dartcraft.proxy.isSimulating(((Entity) this).worldObj)) {
if (this.timeout <= 0)
this.timeout = 40;
} else {
ItemStack contents = getEntityItem();
if (contents != null && contents.getItem() instanceof ItemEntityBottle && this.timeout <= 0) {
if (contents != null && contents.getItem() instanceof ItemEntityBottle
&& this.timeout <= 0) {
this.timeout = 40;
NBTTagCompound comp = contents.getTagCompound();
if (comp.hasKey("Fire") && comp.getShort("Fire") > 0)
comp.setShort("Fire", (short)-1);
comp.setShort("Fire", (short) -1);
if (comp.hasKey("FallDistance") && comp.getFloat("FallDistance") > 0.0F)
comp.setFloat("FallDistance", 0.0F);
short maxHealth = 0;
Entity temp = EntityList.createEntityFromNBT((NBTTagCompound)comp.copy(), ((Entity)this).worldObj);
Entity temp = EntityList.createEntityFromNBT(
(NBTTagCompound) comp.copy(), ((Entity) this).worldObj
);
EntityLivingBase bottled = null;
if (temp instanceof EntityLivingBase)
bottled = (EntityLivingBase)temp;
bottled = (EntityLivingBase) temp;
try {
maxHealth = (short)(int)bottled.getAttributeMap().getAttributeInstanceByName("generic.maxHealth").getAttributeValue();
maxHealth = (short) (int) bottled.getAttributeMap()
.getAttributeInstanceByName("generic.maxHealth")
.getAttributeValue();
} catch (Exception e) {}
if (maxHealth > 0 && comp.hasKey("Health") && comp.getShort("Health") < maxHealth)
comp.setShort("Health", (short)(comp.getShort("Health") + 1));
if (maxHealth > 0 && comp.hasKey("Health")
&& comp.getShort("Health") < maxHealth)
comp.setShort("Health", (short) (comp.getShort("Health") + 1));
}
}
}
@ -93,11 +103,15 @@ public class EntityBottle extends EntityLivingBase implements IBottleRenderable
ItemStack contents = getEntityItem();
bottleStack = (contents != null) ? contents.copy() : null;
if (bottleStack != null) {
Entity entity = EntityList.createEntityFromNBT(bottleStack.getTagCompound(), ((Entity)this).worldObj);
Entity entity = EntityList.createEntityFromNBT(
bottleStack.getTagCompound(), ((Entity) this).worldObj
);
while (entity instanceof EntityBottle) {
EntityBottle bottle = (EntityBottle)entity;
EntityBottle bottle = (EntityBottle) entity;
bottleStack = bottle.getEntityItem();
entity = EntityList.createEntityFromNBT(bottleStack.getTagCompound(), ((Entity)this).worldObj);
entity = EntityList.createEntityFromNBT(
bottleStack.getTagCompound(), ((Entity) this).worldObj
);
iterations++;
}
switch (iterations) {
@ -111,7 +125,8 @@ public class EntityBottle extends EntityLivingBase implements IBottleRenderable
name = name + (iterations + 2) + "x ";
break;
}
name = name + "Bottled " + bottleStack.getTagCompound().getString("dartName");
name = name + "Bottled "
+ bottleStack.getTagCompound().getString("dartName");
}
} catch (Exception e) {
return "Bottled Something";
@ -126,19 +141,28 @@ public class EntityBottle extends EntityLivingBase implements IBottleRenderable
protected void dealFireDamage(int damage) {}
public boolean attackEntityFrom(DamageSource source, float amount) {
if (((Entity)this).isDead || !Dartcraft.proxy.isSimulating(((Entity)this).worldObj))
if (((Entity) this).isDead
|| !Dartcraft.proxy.isSimulating(((Entity) this).worldObj))
return false;
if (source.getEntity() != null && source.getEntity() instanceof EntityPlayer &&
!source.isProjectile()) {
if (source.getEntity() != null && source.getEntity() instanceof EntityPlayer
&& !source.isProjectile()) {
ItemStack contents = getEntityItem();
if (contents != null) {
if (!contents.hasTagCompound())
contents.setTagCompound(new NBTTagCompound());
contents.getTagCompound().setBoolean("wasDropped", true);
}
((Entity)this).worldObj.playSoundAtEntity((Entity)this, "dartcraft:bottle", 2.0F,
EntityUtils.randomPitch());
ItemUtils.dropItem(contents, ((Entity)this).worldObj, ((Entity)this).posX, ((Entity)this).posY, ((Entity)this).posZ);
((Entity) this)
.worldObj.playSoundAtEntity(
(Entity) this, "dartcraft:bottle", 2.0F, EntityUtils.randomPitch()
);
ItemUtils.dropItem(
contents,
((Entity) this).worldObj,
((Entity) this).posX,
((Entity) this).posY,
((Entity) this).posZ
);
setDead();
}
return false;
@ -164,22 +188,22 @@ public class EntityBottle extends EntityLivingBase implements IBottleRenderable
}
public ItemStack getEntityItem() {
return ((Entity)this).getDataWatcher().getWatchableObjectItemStack(12);
return ((Entity) this).getDataWatcher().getWatchableObjectItemStack(12);
}
public void setEntityItem(ItemStack stack) {
((Entity)this).getDataWatcher().updateObject(12, stack);
((Entity) this).getDataWatcher().updateObject(12, stack);
try {
String foundName = stack.getTagCompound().getString("id");
getEntityData().setString("name", foundName);
} catch (Exception e) {
e.printStackTrace();
}
if (Dartcraft.proxy.isSimulating(((Entity)this).worldObj));
if (Dartcraft.proxy.isSimulating(((Entity) this).worldObj))
;
}
public ItemStack getEquipmentInSlot(int slot) {
return null;
}
}

View File

@ -16,7 +16,6 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class EntityFlyingFlask extends EntityThrowable implements IBottleRenderable {
public EntityLivingBase contained;
private boolean creative = false;
@ -31,19 +30,22 @@ public class EntityFlyingFlask extends EntityThrowable implements IBottleRendera
super(world, x, y, z);
}
public EntityFlyingFlask(World world, EntityLivingBase thrower, ItemStack flaskStack) {
public EntityFlyingFlask(
World world, EntityLivingBase thrower, ItemStack flaskStack
) {
super(world, thrower);
try {
if (thrower instanceof EntityPlayer && ((EntityPlayer)thrower).capabilities.isCreativeMode)
if (thrower instanceof EntityPlayer
&& ((EntityPlayer) thrower).capabilities.isCreativeMode)
this.creative = true;
if (flaskStack != null) {
NBTTagCompound comp = (NBTTagCompound)flaskStack.getTagCompound().copy();
NBTTagCompound comp = (NBTTagCompound) flaskStack.getTagCompound().copy();
Entity entity = EntityList.createEntityFromNBT(comp, world);
NBTTagCompound dartTag = EntityUtils.getModComp(entity);
dartTag.removeTag("time");
dartTag.removeTag("timeTime");
dartTag.setInteger("timeImmune", 10);
this.contained = (EntityLivingBase)entity;
this.contained = (EntityLivingBase) entity;
} else {
this.capture = true;
}
@ -54,25 +56,45 @@ public class EntityFlyingFlask extends EntityThrowable implements IBottleRendera
protected void entityInit() {
super.entityInit();
((Entity)this).getDataWatcher().addObject(12, new ItemStack(DartItems.entitybottle));
((Entity) this)
.getDataWatcher()
.addObject(12, new ItemStack(DartItems.entitybottle));
}
protected void onImpact(MovingObjectPosition pos) {
if (Dartcraft.proxy.isSimulating(((Entity)this).worldObj)) {
if (Dartcraft.proxy.isSimulating(((Entity) this).worldObj)) {
if (this.contained != null) {
this.contained.setPosition(((Entity)this).posX, ((Entity)this).posY, ((Entity)this).posZ);
((Entity)this).worldObj.spawnEntityInWorld((Entity)this.contained);
this.contained.setPosition(
((Entity) this).posX, ((Entity) this).posY, ((Entity) this).posZ
);
((Entity) this).worldObj.spawnEntityInWorld((Entity) this.contained);
if (!this.creative) {
ItemStack flaskStack = new ItemStack(DartItems.forceflask);
ItemUtils.dropItem(flaskStack, ((Entity)this).worldObj, ((Entity)this).posX, ((Entity)this).posY, ((Entity)this).posZ);
ItemUtils.dropItem(
flaskStack,
((Entity) this).worldObj,
((Entity) this).posX,
((Entity) this).posY,
((Entity) this).posZ
);
}
((Entity)this).worldObj.playSoundAtEntity((Entity)this, "random.pop", 1.0F,
EntityUtils.randomPitch());
((Entity) this)
.worldObj.playSoundAtEntity(
(Entity) this, "random.pop", 1.0F, EntityUtils.randomPitch()
);
} else if (this.capture) {
if (!bottleEntity(pos.entityHit)) {
((Entity)this).worldObj.playSoundAtEntity((Entity)this, "random.pop", 1.0F,
EntityUtils.randomPitch());
ItemUtils.dropItem(new ItemStack(DartItems.forceflask), ((Entity)this).worldObj, ((Entity)this).posX, ((Entity)this).posY, ((Entity)this).posZ);
((Entity) this)
.worldObj.playSoundAtEntity(
(Entity) this, "random.pop", 1.0F, EntityUtils.randomPitch()
);
ItemUtils.dropItem(
new ItemStack(DartItems.forceflask),
((Entity) this).worldObj,
((Entity) this).posX,
((Entity) this).posY,
((Entity) this).posZ
);
}
}
setDead();
@ -85,14 +107,15 @@ public class EntityFlyingFlask extends EntityThrowable implements IBottleRendera
return false;
EntityLivingBase victim = null;
if (entity instanceof EntityLivingBase)
victim = (EntityLivingBase)entity;
if (victim != null && !((Entity)victim).isDead && victim.getHealth() > 0.0F) {
victim = (EntityLivingBase) entity;
if (victim != null && !((Entity) victim).isDead
&& victim.getHealth() > 0.0F) {
boolean nope = false;
/*boolean whitelisted = !Config.entityWhitelist;
if (!whitelisted && PluginBottles.whitelist != null)
for (String check : PluginBottles.whitelist) {
if (check != null && check.equals(victim.getClass().getCanonicalName())) {
whitelisted = true;
if (check != null &&
check.equals(victim.getClass().getCanonicalName())) { whitelisted = true;
break;
}
}
@ -100,10 +123,14 @@ public class EntityFlyingFlask extends EntityThrowable implements IBottleRendera
nope = true;*/
if (victim instanceof EntityPlayer || victim instanceof EntityBottle)
nope = true;
if (!nope && (victim instanceof net.minecraft.entity.monster.EntityMob || victim instanceof net.minecraft.entity.monster.EntityGhast)) {
if (!nope
&& (victim instanceof net.minecraft.entity.monster.EntityMob
|| victim instanceof net.minecraft.entity.monster.EntityGhast)) {
float maxHealth = 0.0F;
try {
maxHealth = (float)victim.getAttributeMap().getAttributeInstanceByName("generic.maxHealth").getAttributeValue();
maxHealth = (float) victim.getAttributeMap()
.getAttributeInstanceByName("generic.maxHealth")
.getAttributeValue();
} catch (Exception e) {}
float ratio = victim.getHealth() / maxHealth;
float limit = 0.25F;
@ -115,16 +142,32 @@ public class EntityFlyingFlask extends EntityThrowable implements IBottleRendera
dartTag.setInteger("timeImmune", 5);
}
if (nope) {
((Entity)this).worldObj.playSoundAtEntity((Entity)victim, "dartcraft:nope", 2.0F,
EntityUtils.randomPitch());
((Entity) this)
.worldObj.playSoundAtEntity(
(Entity) victim,
"dartcraft:nope",
2.0F,
EntityUtils.randomPitch()
);
return false;
}
ItemStack bottleStack = EntityUtils.bottleEntity((Entity)victim);
((Entity)this).worldObj.playSoundAtEntity((Entity)victim, "dartcraft:swipe", 2.0F,
EntityUtils.randomPitch());
((Entity)this).worldObj.removeEntity((Entity)victim);
ItemStack bottleStack = EntityUtils.bottleEntity((Entity) victim);
((Entity) this)
.worldObj.playSoundAtEntity(
(Entity) victim,
"dartcraft:swipe",
2.0F,
EntityUtils.randomPitch()
);
((Entity) this).worldObj.removeEntity((Entity) victim);
victim = null;
ItemUtils.dropItem(bottleStack, ((Entity)this).worldObj, ((Entity)this).posX, ((Entity)this).posY, ((Entity)this).posZ);
ItemUtils.dropItem(
bottleStack,
((Entity) this).worldObj,
((Entity) this).posX,
((Entity) this).posY,
((Entity) this).posZ
);
}
return true;
} catch (Exception e) {
@ -134,14 +177,13 @@ public class EntityFlyingFlask extends EntityThrowable implements IBottleRendera
}
public ItemStack getEntityItem() {
return ((Entity)this).getDataWatcher().getWatchableObjectItemStack(12);
return ((Entity) this).getDataWatcher().getWatchableObjectItemStack(12);
}
public void setEntityItem(ItemStack stack) {
((Entity)this).getDataWatcher().updateObject(12, stack);
((Entity) this).getDataWatcher().updateObject(12, stack);
try {
getEntityData().setString("name", stack.getTagCompound().getString("id"));
} catch (Exception e) {}
}
}

View File

@ -16,22 +16,33 @@ import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
public class EntityBottleHandler {
@EventHandler
public void handleTaggedPickup(EntityItemPickupEvent event) {
try {
if (((PlayerEvent)event).entityPlayer == null || event.item == null || event.item.getEntityItem() == null)
if (((PlayerEvent) event).entityPlayer == null || event.item == null
|| event.item.getEntityItem() == null)
return;
boolean trigger = false;
if (event.item.getEntityItem().getItem() == DartItems.entitybottle)
if (meshBottles(((PlayerEvent)event).entityPlayer, event.item.getEntityItem())) {
if (meshBottles(
((PlayerEvent) event).entityPlayer, event.item.getEntityItem()
)) {
event.setCanceled(true);
trigger = true;
}
if (Dartcraft.proxy.isSimulating(((Entity)((PlayerEvent)event).entityPlayer).worldObj) && trigger) {
((Entity)((PlayerEvent)event).entityPlayer).worldObj.playSoundAtEntity((Entity)((PlayerEvent)event).entityPlayer, "random.pop", 0.25F,
EntityUtils.randomPitch());
((Entity)((PlayerEvent)event).entityPlayer).worldObj.removeEntity((Entity)event.item);
if (Dartcraft.proxy.isSimulating(
((Entity) ((PlayerEvent) event).entityPlayer).worldObj
)
&& trigger) {
((Entity) ((PlayerEvent) event).entityPlayer)
.worldObj.playSoundAtEntity(
(Entity) ((PlayerEvent) event).entityPlayer,
"random.pop",
0.25F,
EntityUtils.randomPitch()
);
((Entity) ((PlayerEvent) event).entityPlayer)
.worldObj.removeEntity((Entity) event.item);
}
} catch (Exception e) {
e.printStackTrace();
@ -40,9 +51,9 @@ public class EntityBottleHandler {
public static boolean meshBottles(EntityPlayer player, ItemStack item) {
try {
EntityLivingBase entityOne = (EntityLivingBase)EntityList.createEntityFromNBT(item
.getTagCompound(), null);
if (!getHandleEntity((Entity)entityOne))
EntityLivingBase entityOne = (EntityLivingBase
) EntityList.createEntityFromNBT(item.getTagCompound(), null);
if (!getHandleEntity((Entity) entityOne))
return false;
String nameOne = entityOne.getClass().getCanonicalName();
ItemStack[] equipOne = new ItemStack[5];
@ -52,41 +63,60 @@ public class EntityBottleHandler {
String owner = "";
String nameTagName = entityOne.getEntityData().getString("nameTagName");
if (entityOne instanceof EntitySheep)
color = ((EntitySheep)entityOne).getFleeceColor();
if (entityOne instanceof EntityAgeable && ((EntityAgeable)entityOne).isChild())
color = ((EntitySheep) entityOne).getFleeceColor();
if (entityOne instanceof EntityAgeable
&& ((EntityAgeable) entityOne).isChild())
child = true;
if (entityOne instanceof EntityZombie && ((EntityZombie)entityOne).isChild())
if (entityOne instanceof EntityZombie && ((EntityZombie) entityOne).isChild())
child = true;
if (entityOne instanceof EntityZombie && ((EntityZombie)entityOne).isVillager())
if (entityOne instanceof EntityZombie
&& ((EntityZombie) entityOne).isVillager())
villager = true;
if (entityOne instanceof EntityTameable) {
EntityLivingBase owningEntity = ((EntityTameable) entityOne).getOwner();
owner = (owningEntity != null) ? owningEntity.getCommandSenderName() : null;
owner
= (owningEntity != null) ? owningEntity.getCommandSenderName() : null;
}
int i;
for (i = 0; i < 5; i++) {
equipOne[i] = entityOne.getEquipmentInSlot(i);
if (equipOne[i] != null && (!(entityOne instanceof EntityPigZombie) || i != 0 || equipOne[i]
.getItem() != net.minecraft.init.Items.golden_sword))
if (equipOne[i] != null
&& (!(entityOne instanceof EntityPigZombie) || i != 0
|| equipOne[i].getItem() != net.minecraft.init.Items.golden_sword
))
return false;
}
for (i = 0; i < player.inventory.mainInventory.length; i++) {
ItemStack invStack = player.inventory.mainInventory[i];
if (invStack != null && invStack.getItem() == DartItems.entitybottle && invStack
.hasTagCompound() && invStack.stackSize < invStack.getMaxStackSize()) {
EntityLivingBase entityTwo = (EntityLivingBase)EntityList.createEntityFromNBT(invStack
.getTagCompound(), null);
if (invStack != null && invStack.getItem() == DartItems.entitybottle
&& invStack.hasTagCompound()
&& invStack.stackSize < invStack.getMaxStackSize()) {
EntityLivingBase entityTwo = (EntityLivingBase
) EntityList.createEntityFromNBT(invStack.getTagCompound(), null);
if (nameOne.equals(entityTwo.getClass().getCanonicalName()))
if (!(entityTwo instanceof EntitySheep) || ((EntitySheep)entityTwo).getFleeceColor() == color)
if (!(entityTwo instanceof EntityAgeable) || ((EntityAgeable)entityTwo).isChild() == child)
if (!(entityTwo instanceof EntityZombie) || ((EntityZombie)entityTwo).isChild() == child)
if (!(entityTwo instanceof EntityZombie) || ((EntityZombie)entityTwo).isVillager() == villager)
if (!(entityTwo instanceof EntityTameable) || ((EntityTameable)entityTwo).getOwner()
.equals(owner)) {
if (!(entityTwo instanceof EntitySheep)
|| ((EntitySheep) entityTwo).getFleeceColor() == color)
if (!(entityTwo instanceof EntityAgeable)
|| ((EntityAgeable) entityTwo).isChild() == child)
if (!(entityTwo instanceof EntityZombie)
|| ((EntityZombie) entityTwo).isChild() == child)
if (!(entityTwo instanceof EntityZombie)
|| ((EntityZombie) entityTwo).isVillager()
== villager)
if (!(entityTwo instanceof EntityTameable)
|| ((EntityTameable) entityTwo)
.getOwner()
.equals(owner)) {
for (int j = 0; j < 5; j++) {
ItemStack checkStack = entityTwo.getEquipmentInSlot(j);
if (checkStack != null && (!(entityOne instanceof EntityPigZombie) || j != 0 || checkStack
.getItem() != net.minecraft.init.Items.golden_sword))
ItemStack checkStack
= entityTwo.getEquipmentInSlot(j);
if (checkStack != null
&& (!(entityOne
instanceof EntityPigZombie)
|| j != 0
|| checkStack.getItem()
!= net.minecraft.init.Items
.golden_sword))
return false;
}
invStack.stackSize++;
@ -102,9 +132,11 @@ public class EntityBottleHandler {
private static boolean getHandleEntity(Entity entity) {
try {
String name = entity.getClass().getCanonicalName();
Class[] accepted = {
EntityCow.class, EntityChicken.class, EntitySheep.class, EntityPig.class, EntityWolf.class, EntityZombie.class, EntityEnderman.class, EntityGhast.class, EntityBlaze.class, EntityPigZombie.class,
EntitySkeleton.class };
Class[] accepted
= { EntityCow.class, EntityChicken.class, EntitySheep.class,
EntityPig.class, EntityWolf.class, EntityZombie.class,
EntityEnderman.class, EntityGhast.class, EntityBlaze.class,
EntityPigZombie.class, EntitySkeleton.class };
for (Class check : accepted) {
if (name.equals(check.getCanonicalName()))
return true;
@ -114,5 +146,4 @@ public class EntityBottleHandler {
}
return false;
}
}

View File

@ -18,13 +18,12 @@ import net.minecraftforge.event.entity.player.EntityInteractEvent;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
public class EventHandler {
@SubscribeEvent
public void onItemDestroyed(PlayerDestroyItemEvent event) {
ItemStack stack = event.original;
EntityPlayer player = event.entityPlayer;
if (stack != null && stack.getItem() instanceof IBreakable) {
ItemStack ret = ((IBreakable)stack.getItem()).itemReturned();
ItemStack ret = ((IBreakable) stack.getItem()).itemReturned();
if (Dartcraft.proxy.isSimulating(player.worldObj)) {
player.inventory.addItemStackToInventory(ret);
}
@ -41,7 +40,7 @@ public class EventHandler {
return;
if (event.target instanceof EntityAnimal) {
EntityAnimal entity = (EntityAnimal)event.target;
EntityAnimal entity = (EntityAnimal) event.target;
ColdEntityType type = ColdEntityType.fromClass(entity.getClass());
if (type == null)
@ -109,7 +108,7 @@ public class EventHandler {
return new EntityColdPig(world);
case CHICKEN:
return new EntityColdChicken(world);
// why is the compiler so stupid to think that this is required?
default:
return null;
@ -117,7 +116,8 @@ public class EventHandler {
}
ItemStack getDrop() {
// gotta use full names here, because tilera had the brilliant idea to call the mod item class "Items"
// gotta use full names here, because tilera had the brilliant idea to call
// the mod item class "Items"
switch (this) {
case COW:
return new ItemStack(net.minecraft.init.Items.leather);
@ -126,7 +126,7 @@ public class EventHandler {
return new ItemStack(net.minecraft.init.Items.porkchop);
case CHICKEN:
return new ItemStack(net.minecraft.init.Items.feather);
// why is the compiler so stupid to think that this is required?
default:
return null;

View File

@ -4,7 +4,6 @@ import ley.modding.tileralib.api.IIngredient;
import net.minecraft.item.Item;
public class ItemIngredient implements IIngredient {
char key;
int count;
Item item;

View File

@ -1,18 +1,23 @@
package ley.modding.dartcraft.internal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cpw.mods.fml.common.registry.GameRegistry;
import ley.modding.dartcraft.Dartcraft;
import ley.modding.tileralib.api.ICustomItemBlockProvider;
import ley.modding.tileralib.api.IIngredient;
import ley.modding.tileralib.api.IRegistry;
import ley.modding.tileralib.api.ITEProvider;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import java.util.*;
public class Registry implements IRegistry {
Map<String, Item> items;
Map<String, Block> blocks;
@ -43,7 +48,8 @@ public class Registry implements IRegistry {
}
@Override
public void addShapedRecipe(ItemStack output, String[] pattern, IIngredient[] ingredients) {
public void
addShapedRecipe(ItemStack output, String[] pattern, IIngredient[] ingredients) {
List<Object> objects = new ArrayList<Object>(Arrays.asList(pattern));
for (IIngredient i : ingredients) {
objects.add(i.getKey());
@ -79,13 +85,16 @@ public class Registry implements IRegistry {
if (block != null) {
String id = block.getUnlocalizedName().toLowerCase().split("\\.")[1];
blocks.put(id, block);
GameRegistry.registerBlock(block, id);
Class<? extends ItemBlock> itemBlockClass
= block instanceof ICustomItemBlockProvider
? ((ICustomItemBlockProvider) block).getItemBlockClass()
: ItemBlock.class;
GameRegistry.registerBlock(block, itemBlockClass, id);
if (block instanceof ITEProvider) {
GameRegistry.registerTileEntity(((ITEProvider) block).getTEClass(),id);
GameRegistry.registerTileEntity(((ITEProvider) block).getTEClass(), id);
}
return block;
}
return null;
}
}

View File

@ -1,11 +1,9 @@
package ley.modding.dartcraft.item;
import ley.modding.dartcraft.Dartcraft;
import ley.modding.dartcraft.util.Util;
import net.minecraft.item.Item;
public class BaseItem extends Item {
public class BaseItem extends Item {
public BaseItem(String id) {
Util.configureItem(this, id);
}

View File

@ -1,5 +1,6 @@
package ley.modding.dartcraft.item;
import ley.modding.dartcraft.block.DartBlocks;
import ley.modding.dartcraft.item.tool.ItemForceAxe;
import ley.modding.dartcraft.item.tool.ItemForceMitts;
import ley.modding.dartcraft.item.tool.ItemForcePickaxe;
@ -9,49 +10,46 @@ import ley.modding.tileralib.api.IRegistry;
import net.minecraft.item.Item;
public class DartItems {
public static Item clipboard;
public static Item entitybottle;
public static Item forceaxe;
public static Item forceflask;
public static Item forcegem;
public static Item forceingot;
public static Item forcemitts;
public static Item forcenugget;
public static Item forcestick;
public static Item forcepickaxe;
public static Item forceshard;
public static Item forceshears;
public static Item forcepickaxe;
public static Item forceshovel;
public static Item forceaxe;
public static Item forcemitts;
public static Item forceflask;
public static Item entitybottle;
public static Item clipboard;
public static Item forcestick;
//Useless Items
public static Item fortune;
public static Item soulwafer;
// Useless Items
public static Item claw;
public static Item fortune;
public static Item goldenpower;
public static Item resource;
public static Item soulwafer;
public static void regsiter(IRegistry reg) {
DartItems.entitybottle = reg.registerItem(new ItemEntityBottle());
DartItems.forceaxe = reg.registerItem(new ItemForceAxe());
DartItems.forceflask = reg.registerItem(new ItemForceFlask());
DartItems.forcegem = reg.registerItem(new BaseItem("forcegem"));
DartItems.forceingot = reg.registerItem(new BaseItem("forceingot"));
DartItems.forcenugget = reg.registerItem(new BaseItem("forcenugget"));
DartItems.forcestick = reg.registerItem(new BaseItem("forcestick"));
DartItems.forceshard = reg.registerItem(new BaseItem("forceshard"));
DartItems.forcemitts = reg.registerItem(new ItemForceMitts());
DartItems.forcenugget = reg.registerItem(new BaseItem("forcenugget"));
DartItems.forcepickaxe = reg.registerItem(new ItemForcePickaxe());
DartItems.forceshovel = reg.registerItem(new ItemForceShovel());
DartItems.forceaxe = reg.registerItem(new ItemForceAxe());
DartItems.forceshard = reg.registerItem(new BaseItem("forceshard"));
DartItems.forceshears = reg.registerItem(new ItemForceShears());
DartItems.forceflask = reg.registerItem(new ItemForceFlask());
DartItems.entitybottle = reg.registerItem(new ItemEntityBottle());
DartItems.forceshovel = reg.registerItem(new ItemForceShovel());
DartItems.forcestick = reg.registerItem(new BaseItem("forcestick"));
DartItems.fortune = reg.registerItem(new BaseItem("fortune"));
DartItems.soulwafer = reg.registerItem(new BaseItem("soulwafer"));
DartItems.claw = reg.registerItem(new BaseItem("claw"));
DartItems.clipboard = reg.registerItem(new ItemClipboard());
DartItems.fortune = reg.registerItem(new BaseItem("fortune"));
DartItems.goldenpower = reg.registerItem(new BaseItem("goldenpower"));
DartItems.resource = reg.registerItem(new BaseItem("resource"));
DartItems.clipboard = reg.registerItem(new ItemClipboard());
DartItems.soulwafer = reg.registerItem(new BaseItem("soulwafer"));
}
}

View File

@ -0,0 +1,24 @@
package ley.modding.dartcraft.item;
import ley.modding.dartcraft.util.Util;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockForceBrick extends ItemBlock {
public ItemBlockForceBrick(Block block) {
super(block);
Util.configureItem(this, "forcebrick");
this.setHasSubtypes(true);
}
@Override
public int getMetadata(int damage) {
return damage;
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return "tile.forcebrick" + stack.getItemDamage();
}
}

View File

@ -13,15 +13,14 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
public class ItemClipboard extends Item {
public ItemClipboard() {
Util.configureItem(this, "clipboard");
setMaxStackSize(1);
}
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
public void
onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
if (stack == null)
return;
if (!stack.hasTagCompound())
@ -36,21 +35,27 @@ public class ItemClipboard extends Item {
NBTTagList contents = new NBTTagList();
for (int i = 0; i < 9; i++) {
NBTTagCompound itemComp = new NBTTagCompound();
itemComp.setByte("Slot", (byte)i);
itemComp.setByte("Slot", (byte) i);
contents.appendTag((NBTBase) itemComp);
}
comp.setTag("contents", (NBTBase)contents);
comp.setTag("contents", (NBTBase) contents);
stack.setTagCompound(comp);
}
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (stack.hasTagCompound()) {
NBTTagCompound dartTag = EntityUtils.getModComp((Entity)player);
NBTTagCompound dartTag = EntityUtils.getModComp((Entity) player);
dartTag.setInteger("toOpen", stack.getTagCompound().getInteger("ID"));
if (Dartcraft.proxy.isSimulating(world))
player.openGui(Dartcraft.instance, 0, world, (int)((Entity)player).posX, (int)((Entity)player).posY, (int)((Entity)player).posZ);
player.openGui(
Dartcraft.instance,
0,
world,
(int) ((Entity) player).posX,
(int) ((Entity) player).posY,
(int) ((Entity) player).posZ
);
}
return stack;
}
}

View File

@ -26,7 +26,6 @@ import net.minecraft.world.World;
import java.util.List;
public class ItemEntityBottle extends Item {
public static final int ENTITY_META = 0;
public static final int AREA_META = 1;
@ -41,17 +40,20 @@ public class ItemEntityBottle extends Item {
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean thing) {
public void
addInformation(ItemStack stack, EntityPlayer player, List list, boolean thing) {
if (stack.hasTagCompound()) {
NBTTagCompound comp = (NBTTagCompound)stack.getTagCompound().copy();
NBTTagCompound comp = (NBTTagCompound) stack.getTagCompound().copy();
if (stack.getItemDamage() == 0) {
Entity entity = null;
if (comp.hasKey("CanPickUpLoot"))
entity = EntityList.createEntityFromNBT(comp, ((Entity)player).worldObj);
entity = EntityList.createEntityFromNBT(
comp, ((Entity) player).worldObj
);
if (comp != null && comp.hasKey("dartName")) {
String name = null;
if (entity instanceof EntityBottle)
name = ((EntityBottle)entity).getBottledName();
name = ((EntityBottle) entity).getBottledName();
if (name != null) {
list.clear();
list.add(name);
@ -79,7 +81,7 @@ public class ItemEntityBottle extends Item {
return super.getItemStackDisplayName(stack);
if (stack.getItemDamage() == 0) {
String name = stack.getTagCompound().getString("dartName");
NBTTagCompound comp = (NBTTagCompound)stack.getTagCompound().copy();
NBTTagCompound comp = (NBTTagCompound) stack.getTagCompound().copy();
if (name.equals("entity.DartCraft.entityBeeSwarm.name"))
return "Flask of Angry Bees";
if (name.equals("entity.DartCraft.entityFairy.name"))
@ -92,31 +94,52 @@ public class ItemEntityBottle extends Item {
return super.getItemStackDisplayName(stack);
}
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
public void
onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
if (stack == null || !Dartcraft.proxy.isSimulating(world))
return;
if (stack.getItemDamage() == 0) {
if (stack.hasTagCompound())
stack.getTagCompound().setInteger("timeout", stack.getTagCompound().getInteger("timeout") + 1);
stack.getTagCompound().setInteger(
"timeout", stack.getTagCompound().getInteger("timeout") + 1
);
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("wasDropped"))
stack.getTagCompound().removeTag("wasDropped");
if (stack != null && stack.getItem() instanceof ItemEntityBottle && stack.hasTagCompound() && stack
.getTagCompound().getInteger("timeout") >= 40) {
if (stack != null && stack.getItem() instanceof ItemEntityBottle
&& stack.hasTagCompound()
&& stack.getTagCompound().getInteger("timeout") >= 40) {
stack.getTagCompound().setInteger("timeout", 0);
NBTTagCompound comp = stack.getTagCompound();
String name = comp.getString("dartName");
if (name != null && name.equals("Creeper")) {
boolean bane = (comp.hasKey("ForgeData") && comp.getCompoundTag("ForgeData").hasKey("DartCraft") && comp.getCompoundTag("ForgeData").getCompoundTag("DartCraft").getBoolean("baned"));
boolean bane
= (comp.hasKey("ForgeData")
&& comp.getCompoundTag("ForgeData").hasKey("DartCraft")
&& comp.getCompoundTag("ForgeData")
.getCompoundTag("DartCraft")
.getBoolean("baned"));
if (!bane && entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer)entity;
world.createExplosion((Entity)new EntityCreeper(world), ((Entity)player).posX, ((Entity)player).posY, ((Entity)player).posZ, 0.25F, false);
EntityPlayer player = (EntityPlayer) entity;
world.createExplosion(
(Entity) new EntityCreeper(world),
((Entity) player).posX,
((Entity) player).posY,
((Entity) player).posZ,
0.25F,
false
);
comp.setBoolean("dartToDestroy", true);
for (int i = 0; i < player.inventory.mainInventory.length; i++) {
ItemStack tempStack = player.inventory.mainInventory[i];
if (tempStack != null && tempStack.getItem() instanceof ItemEntityBottle && tempStack
.hasTagCompound() && tempStack.getTagCompound().hasKey("dartToDestroy") && tempStack
.getTagCompound().getBoolean("dartToDestroy")) {
//player.inventory.setInventorySlotContents(i, new ItemStack(PAItems.resource, CommonProxy.rand.nextInt(3) + 1, 3));
if (tempStack != null
&& tempStack.getItem() instanceof ItemEntityBottle
&& tempStack.hasTagCompound()
&& tempStack.getTagCompound().hasKey("dartToDestroy")
&& tempStack.getTagCompound().getBoolean("dartToDestroy"
)) {
//player.inventory.setInventorySlotContents(i, new
//ItemStack(PAItems.resource, CommonProxy.rand.nextInt(3)
//+ 1, 3));
break;
}
}
@ -124,27 +147,43 @@ public class ItemEntityBottle extends Item {
}
}
if (comp.hasKey("Fire") && comp.getShort("Fire") > 0)
comp.setShort("Fire", (short)-1);
comp.setShort("Fire", (short) -1);
if (comp.hasKey("FallDistance") && comp.getFloat("FallDistance") > 0.0F)
comp.setFloat("FallDistance", 0.0F);
short maxHealth = 0;
Entity temp = EntityList.createEntityFromNBT((NBTTagCompound)comp.copy(), world);
Entity temp
= EntityList.createEntityFromNBT((NBTTagCompound) comp.copy(), world);
EntityLivingBase bottled = null;
if (temp instanceof EntityLivingBase)
bottled = (EntityLivingBase)temp;
bottled = (EntityLivingBase) temp;
try {
maxHealth = (short)(int)bottled.getAttributeMap().getAttributeInstanceByName("generic.maxHealth").getAttributeValue();
maxHealth = (short) (int) bottled.getAttributeMap()
.getAttributeInstanceByName("generic.maxHealth")
.getAttributeValue();
} catch (Exception e) {}
if (maxHealth > 0 && comp.hasKey("Health") && comp.getShort("Health") < maxHealth)
comp.setShort("Health", (short)(comp.getShort("Health") + 1));
if (maxHealth > 0 && comp.hasKey("Health")
&& comp.getShort("Health") < maxHealth)
comp.setShort("Health", (short) (comp.getShort("Health") + 1));
}
}
}
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
public boolean onItemUseFirst(
ItemStack stack,
EntityPlayer player,
World world,
int x,
int y,
int z,
int side,
float hitX,
float hitY,
float hitZ
) {
try {
if (!Dartcraft.proxy.isSimulating(world) || stack == null || stack
.getItemDamage() == 1);
if (!Dartcraft.proxy.isSimulating(world) || stack == null
|| stack.getItemDamage() == 1)
;
} catch (Exception e) {
e.printStackTrace();
}
@ -159,24 +198,34 @@ public class ItemEntityBottle extends Item {
if (!thrown) {
spawnEntity(world, player, stack);
} else {
EntityFlyingFlask flask = new EntityFlyingFlask(world, (EntityLivingBase)player, stack);
world.spawnEntityInWorld((Entity)flask);
EntityFlyingFlask flask = new EntityFlyingFlask(
world, (EntityLivingBase) player, stack
);
world.spawnEntityInWorld((Entity) flask);
flask.setEntityItem(stack.copy());
world.playSoundAtEntity((Entity)player, "random.bow", 1.0F,
EntityUtils.randomPitch());
world.playSoundAtEntity(
(Entity) player, "random.bow", 1.0F, EntityUtils.randomPitch()
);
}
stack.stackSize--;
if (!thrown) {
if (stack.stackSize > 0) {
if (!player.inventory.addItemStackToInventory(new ItemStack(DartItems.forceflask)))
if (!player.inventory.addItemStackToInventory(
new ItemStack(DartItems.forceflask)
))
if (Dartcraft.proxy.isSimulating(world))
ItemUtils.dropItem(new ItemStack(DartItems.forceflask), world, ((Entity)player).posX, ((Entity)player).posY, ((Entity)player).posZ);
ItemUtils.dropItem(
new ItemStack(DartItems.forceflask),
world,
((Entity) player).posX,
((Entity) player).posY,
((Entity) player).posZ
);
return stack;
}
return new ItemStack(DartItems.forceflask);
}
} else if (stack.getItemDamage() == 1) {
}
} catch (Exception e) {
e.printStackTrace();
@ -186,24 +235,37 @@ public class ItemEntityBottle extends Item {
private void spawnEntity(World world, EntityPlayer player, ItemStack stack) {
if (stack != null && stack.hasTagCompound()) {
NBTTagCompound comp = (NBTTagCompound)stack.getTagCompound().copy();
NBTTagCompound comp = (NBTTagCompound) stack.getTagCompound().copy();
Entity entity = EntityList.createEntityFromNBT(comp, world);
if (entity != null && entity instanceof EntityLivingBase) {
double xIncr = (-MathHelper.sin(((Entity)player).rotationYaw / 180.0F * 3.1415927F) * MathHelper.cos(((Entity)player).rotationPitch / 180.0F * 3.1415927F));
double yIncr = -MathHelper.sin(((Entity)player).rotationPitch / 180.0F * 3.1415927F);
double zIncr = (MathHelper.cos(((Entity)player).rotationYaw / 180.0F * 3.1415927F) * MathHelper.cos(((Entity)player).rotationPitch / 180.0F * 3.1415927F));
double x = ((Entity)player).posX + xIncr * 2.0D;
double y = ((Entity)player).posY;
double z = ((Entity)player).posZ + zIncr * 2.0D;
EntityLivingBase restored = (EntityLivingBase)entity;
double xIncr
= (-MathHelper.sin(
((Entity) player).rotationYaw / 180.0F * 3.1415927F
)
* MathHelper.cos(
((Entity) player).rotationPitch / 180.0F * 3.1415927F
));
double yIncr = -MathHelper.sin(
((Entity) player).rotationPitch / 180.0F * 3.1415927F
);
double zIncr
= (MathHelper.cos(((Entity) player).rotationYaw / 180.0F * 3.1415927F)
* MathHelper.cos(
((Entity) player).rotationPitch / 180.0F * 3.1415927F
));
double x = ((Entity) player).posX + xIncr * 2.0D;
double y = ((Entity) player).posY;
double z = ((Entity) player).posZ + zIncr * 2.0D;
EntityLivingBase restored = (EntityLivingBase) entity;
restored.setPosition(x, y, z);
NBTTagCompound dartTag = EntityUtils.getModComp((Entity)restored);
NBTTagCompound dartTag = EntityUtils.getModComp((Entity) restored);
dartTag.removeTag("time");
dartTag.removeTag("timeTime");
dartTag.setInteger("timeImmune", 10);
world.spawnEntityInWorld((Entity)restored);
world.playSoundAtEntity((Entity)player, "dartcraft:bottle", 2.0F,
EntityUtils.randomPitch());
world.spawnEntityInWorld((Entity) restored);
world.playSoundAtEntity(
(Entity) player, "dartcraft:bottle", 2.0F, EntityUtils.randomPitch()
);
}
}
}
@ -211,8 +273,12 @@ public class ItemEntityBottle extends Item {
public boolean hasCustomEntity(ItemStack stack) {
if (stack == null || !stack.hasTagCompound())
return false;
return ((!stack.getTagCompound().getBoolean("wasDropped") && stack.getItemDamage() == 0) || (
!stack.getTagCompound().hasKey("specialID") && stack.getItemDamage() == 1 && stack.stackSize < 2));
return (
(!stack.getTagCompound().getBoolean("wasDropped")
&& stack.getItemDamage() == 0)
|| (!stack.getTagCompound().hasKey("specialID") && stack.getItemDamage() == 1
&& stack.stackSize < 2)
);
}
public Entity createEntity(World world, Entity entity, ItemStack stack) {
@ -220,11 +286,13 @@ public class ItemEntityBottle extends Item {
return null;
try {
if (stack.getItemDamage() == 0) {
EntityBottle item = new EntityBottle(world, entity.posX, entity.posY, entity.posZ, stack);
((Entity)item).motionX = entity.motionX;
((Entity)item).motionY = entity.motionY;
((Entity)item).motionZ = entity.motionZ;
return (Entity)item;
EntityBottle item = new EntityBottle(
world, entity.posX, entity.posY, entity.posZ, stack
);
((Entity) item).motionX = entity.motionX;
((Entity) item).motionY = entity.motionY;
((Entity) item).motionZ = entity.motionZ;
return (Entity) item;
}
} catch (Exception e) {
e.printStackTrace();
@ -235,15 +303,14 @@ public class ItemEntityBottle extends Item {
@Override
public void getSubItems(Item par1, CreativeTabs tabs, List list) {
try {
list.add(EntityUtils.bottleEntity((Entity)new EntityCow(null)));
list.add(EntityUtils.bottleEntity((Entity)new EntityPig(null)));
list.add(EntityUtils.bottleEntity((Entity)new EntityChicken(null)));
list.add(EntityUtils.bottleEntity((Entity) new EntityCow(null)));
list.add(EntityUtils.bottleEntity((Entity) new EntityPig(null)));
list.add(EntityUtils.bottleEntity((Entity) new EntityChicken(null)));
EntitySkeleton skeleton = new EntitySkeleton(null);
skeleton.setSkeletonType(1);
list.add(EntityUtils.bottleEntity((Entity)skeleton));
list.add(EntityUtils.bottleEntity((Entity) skeleton));
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -22,7 +22,6 @@ import net.minecraft.world.World;
import java.util.List;
public class ItemForceFlask extends Item {
public static final int EMPTY_META = 0;
public static final int MILK_META = 1;
@ -61,18 +60,19 @@ public class ItemForceFlask extends Item {
return new ItemStack(this, 1, 0);
}
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
public void
onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
try {
if (Dartcraft.proxy.isSimulating(world) && stack != null && entity != null && entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer)entity;
if (Dartcraft.proxy.isSimulating(world) && stack != null && entity != null
&& entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
if (stack.getItemDamage() == 2 || stack.getItemDamage() == 1) {
if (!stack.hasTagCompound())
stack.setTagCompound(new NBTTagCompound());
if (stack.getTagCompound().hasKey("triedCraft") && stack.getTagCompound()
.getBoolean("triedCraft"))
if (stack.getTagCompound().hasKey("triedCraft")
&& stack.getTagCompound().getBoolean("triedCraft"))
stack.getTagCompound().removeTag("triedCraft");
} else if (stack.getItemDamage() != 0 || stack.stackSize == 0) {
}
}
} catch (Exception e) {
@ -83,33 +83,35 @@ public class ItemForceFlask extends Item {
public String getUnlocalizedName(ItemStack stack) {
String name = "item.forceflask_";
if (stack != null)
switch (stack.getItemDamage()) {
case 0:
name = name + "empty";
break;
case 1:
name = name + "milk";
break;
case 4:
name = name + "potion_green";
break;
case 6:
name = name + "potion_blue";
break;
case 5:
name = name + "potion_red";
break;
case 3:
name = name + "potion_chateau";
break;
case 2:
name = name + "potion_force";
break;
}
switch (stack.getItemDamage()) {
case 0:
name = name + "empty";
break;
case 1:
name = name + "milk";
break;
case 4:
name = name + "potion_green";
break;
case 6:
name = name + "potion_blue";
break;
case 5:
name = name + "potion_red";
break;
case 3:
name = name + "potion_chateau";
break;
case 2:
name = name + "potion_force";
break;
}
return name;
}
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) {
public boolean itemInteractionForEntity(
ItemStack stack, EntityPlayer player, EntityLivingBase entity
) {
try {
if (stack.getItemDamage() == 0)
if (entity instanceof net.minecraft.entity.passive.EntityCow) {
@ -126,15 +128,15 @@ public class ItemForceFlask extends Item {
public EnumAction getItemUseAction(ItemStack stack) {
try {
switch (stack.getItemDamage()) {
case 1:
case 5:
case 4:
case 2:
case 6:
case 3:
return EnumAction.drink;
}
switch (stack.getItemDamage()) {
case 1:
case 5:
case 4:
case 2:
case 6:
case 3:
return EnumAction.drink;
}
} catch (Exception e) {
e.printStackTrace();
}
@ -144,18 +146,21 @@ public class ItemForceFlask extends Item {
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
try {
if (stack.getItemDamage() == 0 && player.isSneaking()) {
if (Dartcraft.proxy.isSimulating(world)) {
EntityFlyingFlask flask = new EntityFlyingFlask(world, (EntityLivingBase)player, null);
world.spawnEntityInWorld((Entity)flask);
world.playSoundAtEntity((Entity)player, "random.bow", 1.0F,
EntityUtils.randomPitch());
}
stack.stackSize--;
if (Dartcraft.proxy.isSimulating(world)) {
EntityFlyingFlask flask
= new EntityFlyingFlask(world, (EntityLivingBase) player, null);
world.spawnEntityInWorld((Entity) flask);
world.playSoundAtEntity(
(Entity) player, "random.bow", 1.0F, EntityUtils.randomPitch()
);
}
stack.stackSize--;
return stack;
}
NBTTagCompound dartTag = EntityUtils.getModComp((Entity)player);
if ((stack.getItemDamage() >= 32 && stack.hasTagCompound() && stack
.getTagCompound().getFloat("amount") >= 1.0F) || stack.getItemDamage() == 1)
NBTTagCompound dartTag = EntityUtils.getModComp((Entity) player);
if ((stack.getItemDamage() >= 32 && stack.hasTagCompound()
&& stack.getTagCompound().getFloat("amount") >= 1.0F)
|| stack.getItemDamage() == 1)
player.setItemInUse(stack, getMaxItemUseDuration(stack));
} catch (Exception e) {
e.printStackTrace();
@ -186,8 +191,8 @@ public class ItemForceFlask extends Item {
public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) {
if (stack == null || world == null || player == null)
return stack;
NBTTagCompound dartTag = EntityUtils.getModComp((Entity)player);
boolean server = Dartcraft.proxy.isSimulating(((Entity)player).worldObj);
NBTTagCompound dartTag = EntityUtils.getModComp((Entity) player);
boolean server = Dartcraft.proxy.isSimulating(((Entity) player).worldObj);
if (dartTag.hasKey("lastPotion"))
return stack;
if (dartTag.hasKey("combatTime"))
@ -199,7 +204,9 @@ public class ItemForceFlask extends Item {
if (server) {
player.clearActivePotions();
player.heal(4.0F);
world.playSoundAtEntity((Entity)player, "dartcraft:heart", 1.0F, 1.0F);
world.playSoundAtEntity(
(Entity) player, "dartcraft:heart", 1.0F, 1.0F
);
return reduceContainer(player, stack);
}
break;
@ -223,22 +230,23 @@ public class ItemForceFlask extends Item {
return stack;
}
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
if (!Dartcraft.proxy.isSimulating(((Entity)player).worldObj) || stack == null || stack
.getItemDamage() != 0)
public boolean
onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
if (!Dartcraft.proxy.isSimulating(((Entity) player).worldObj) || stack == null
|| stack.getItemDamage() != 0)
return true;
World world = ((Entity)player).worldObj;
World world = ((Entity) player).worldObj;
EntityLivingBase victim = null;
if (entity instanceof EntityLivingBase)
victim = (EntityLivingBase)entity;
if (victim != null && !((Entity)victim).isDead && victim.getHealth() > 0.0F) {
victim = (EntityLivingBase) entity;
if (victim != null && !((Entity) victim).isDead && victim.getHealth() > 0.0F) {
boolean nope = false;
//TODO Whitelist
/*boolean whitelisted = !Config.entityWhitelist;
if (!whitelisted && PluginBottles.whitelist != null)
for (String check : PluginBottles.whitelist) {
if (check != null && check.equals(victim.getClass().getCanonicalName())) {
whitelisted = true;
if (check != null &&
check.equals(victim.getClass().getCanonicalName())) { whitelisted = true;
break;
}
}
@ -246,16 +254,20 @@ public class ItemForceFlask extends Item {
nope = true;*/
if (victim instanceof EntityPlayer || victim instanceof EntityBottle)
nope = true;
if (!nope && (victim instanceof net.minecraft.entity.monster.EntityMob || victim instanceof net.minecraft.entity.monster.EntityGhast)) {
if (!nope
&& (victim instanceof net.minecraft.entity.monster.EntityMob
|| victim instanceof net.minecraft.entity.monster.EntityGhast)) {
float maxHealth = 0.0F;
try {
maxHealth = (float)victim.getAttributeMap().getAttributeInstanceByName("generic.maxHealth").getAttributeValue();
maxHealth = (float) victim.getAttributeMap()
.getAttributeInstanceByName("generic.maxHealth")
.getAttributeValue();
} catch (Exception e) {}
float ratio = victim.getHealth() / maxHealth;
float limit = 0.25F;
if (ratio >= limit && maxHealth >= 5.0F)
nope = true;
NBTTagCompound dartTag = EntityUtils.getModComp((Entity)victim);
NBTTagCompound dartTag = EntityUtils.getModComp((Entity) victim);
if (player.capabilities.isCreativeMode)
nope = false;
dartTag.removeTag("time");
@ -263,14 +275,16 @@ public class ItemForceFlask extends Item {
dartTag.setInteger("timeImmune", 5);
}
if (nope) {
world.playSoundAtEntity((Entity) victim, "dartcraft:nope", 2.0F,
EntityUtils.randomPitch());
world.playSoundAtEntity(
(Entity) victim, "dartcraft:nope", 2.0F, EntityUtils.randomPitch()
);
return true;
}
ItemStack bottleStack = EntityUtils.bottleEntity((Entity)victim);
world.playSoundAtEntity((Entity)victim, "dartcraft:swipe", 2.0F,
EntityUtils.randomPitch());
world.removeEntity((Entity)victim);
ItemStack bottleStack = EntityUtils.bottleEntity((Entity) victim);
world.playSoundAtEntity(
(Entity) victim, "dartcraft:swipe", 2.0F, EntityUtils.randomPitch()
);
world.removeEntity((Entity) victim);
victim = null;
stack.stackSize--;
if (stack.stackSize <= 0) {
@ -278,7 +292,13 @@ public class ItemForceFlask extends Item {
} else if (!EntityBottleHandler.meshBottles(player, bottleStack)) {
if (!player.inventory.addItemStackToInventory(bottleStack))
if (Dartcraft.proxy.isSimulating(world))
ItemUtils.dropItem(bottleStack, world, ((Entity)player).posX, ((Entity)player).posY, ((Entity)player).posZ);
ItemUtils.dropItem(
bottleStack,
world,
((Entity) player).posX,
((Entity) player).posY,
((Entity) player).posZ
);
}
}
return true;
@ -290,5 +310,4 @@ public class ItemForceFlask extends Item {
for (int i : toAdd)
itemList.add(new ItemStack(this, 1, i));
}
}

View File

@ -14,11 +14,12 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.EnumHelper;
public class ItemForceAxe extends ItemAxe implements IBreakable, IForceConsumer {
private static int damage = 1;
private static float efficiency = 5.0F;
private static int toolLevel = 10;
public static ToolMaterial material = EnumHelper.addToolMaterial("FORCE", toolLevel, 512, efficiency, (float) damage, 0);
public static ToolMaterial material = EnumHelper.addToolMaterial(
"FORCE", toolLevel, 512, efficiency, (float) damage, 0
);
public ItemForceAxe() {
super(material);
@ -31,7 +32,9 @@ public class ItemForceAxe extends ItemAxe implements IBreakable, IForceConsumer
stack.setTagCompound(new NBTTagCompound());
}
stack.getTagCompound().setBoolean("active", !stack.getTagCompound().getBoolean("active"));
stack.getTagCompound().setBoolean(
"active", !stack.getTagCompound().getBoolean("active")
);
if (!Dartcraft.proxy.isSimulating(world)) {
if (stack.getTagCompound().getBoolean("active")) {
Dartcraft.proxy.sendChatToPlayer(player, "Area mode activated.");

View File

@ -25,11 +25,12 @@ import java.util.HashSet;
import java.util.Set;
public class ItemForceMitts extends ItemTool implements IBreakable, IToolGrafter {
private static int damage = 0;
private static float efficiency = 16.0F;
private static int toolLevel = 4;
public static ToolMaterial material = EnumHelper.addToolMaterial("FORCE", toolLevel, 256, efficiency, (float)damage, 0);
public static ToolMaterial material = EnumHelper.addToolMaterial(
"FORCE", toolLevel, 256, efficiency, (float) damage, 0
);
public ArrayList<Block> mineableBlocks = new ArrayList<Block>();
private int range = 2;
@ -86,17 +87,21 @@ public class ItemForceMitts extends ItemTool implements IBreakable, IToolGrafter
@Override
public boolean canHarvestBlock(Block block, ItemStack itemStack) {
return this.mineableBlocks.contains(block) || block.getMaterial() == Material.leaves || block.getMaterial() == Material.wood;
return this.mineableBlocks.contains(block)
|| block.getMaterial() == Material.leaves
|| block.getMaterial() == Material.wood;
}
@Override
public boolean hitEntity(ItemStack itemStack, EntityLivingBase entity, EntityLivingBase player) {
public boolean
hitEntity(ItemStack itemStack, EntityLivingBase entity, EntityLivingBase player) {
return true;
}
@Override
public float getDigSpeed(ItemStack stack, Block block, int meta) {
if(!ForgeHooks.isToolEffective(stack, block, meta) && !this.canHarvestBlock(block, stack)) {
if (!ForgeHooks.isToolEffective(stack, block, meta)
&& !this.canHarvestBlock(block, stack)) {
return 1.0F;
} else {
return this.efficiencyOnProperMaterial; //TODO Upgrades
@ -104,7 +109,18 @@ public class ItemForceMitts extends ItemTool implements IBreakable, IToolGrafter
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) {
public boolean onItemUse(
ItemStack stack,
EntityPlayer player,
World world,
int x,
int y,
int z,
int par7,
float par8,
float par9,
float par10
) {
if (!player.canPlayerEdit(x, y, z, par7, stack)) {
return false;
} else {
@ -119,42 +135,48 @@ public class ItemForceMitts extends ItemTool implements IBreakable, IToolGrafter
Block block = world.getBlock(x, y, z);
if (par7 != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt))
{
if (par7 != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z)
&& (block == Blocks.grass || block == Blocks.dirt)) {
Block block1 = Blocks.farmland;
world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);
world.playSoundEffect(
(double) ((float) x + 0.5F),
(double) ((float) y + 0.5F),
(double) ((float) z + 0.5F),
block1.stepSound.getStepResourcePath(),
(block1.stepSound.getVolume() + 1.0F) / 2.0F,
block1.stepSound.getPitch() * 0.8F
);
if (world.isRemote)
{
if (world.isRemote) {
return true;
}
else
{
} else {
world.setBlock(x, y, z, block1);
stack.damageItem(1, player);
return true;
}
}
else
{
} else {
return false;
}
}
@Override
public float getSaplingModifier(ItemStack stack, World world, EntityPlayer player, int x, int y, int z) {
public float getSaplingModifier(
ItemStack stack, World world, EntityPlayer player, int x, int y, int z
) {
return 100.0F;
}
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
public boolean
onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
World world = player.worldObj;
if(!Dartcraft.proxy.isSimulating(world)) {
if (!Dartcraft.proxy.isSimulating(world)) {
return false;
} else {
Block block = world.getBlock(x, y, z);
if (block != null) {
Material mat = block.getMaterial();
if ((!(block instanceof BlockFlower)) && (mat == null || mat != Material.leaves)) {
if ((!(block instanceof BlockFlower))
&& (mat == null || mat != Material.leaves)) {
return false;
} else {
for (int i = 0 - this.range; i < 1 + this.range; ++i) {
@ -164,11 +186,25 @@ public class ItemForceMitts extends ItemTool implements IBreakable, IToolGrafter
int newY = y + j;
int newZ = z + k;
Block block2 = world.getBlock(newX, newY, newZ);
if (block2 instanceof BlockFlower || block2 != null && block2.getMaterial() == Material.leaves) {
world.getBlock(x + i, y + j, z + k).harvestBlock(world, player, x + i, y + j, z + k, world.getBlockMetadata(x + i, y + j, z + k));
if (block2 instanceof BlockFlower
|| block2 != null
&& block2.getMaterial() == Material.leaves) {
world.getBlock(x + i, y + j, z + k)
.harvestBlock(
world,
player,
x + i,
y + j,
z + k,
world.getBlockMetadata(x + i, y + j, z + k)
);
world.setBlockToAir(x + i, y + j, z + k);
if (i == 0 && j == 0 && k == 0) {
//PacketDispatcher.sendPacketToAllAround((double) x, (double) y, (double) z, 30.0D, player.field_71093_bK, (new FXPacket(17, (double) x, (double) y, (double) z)).getPacket());
//PacketDispatcher.sendPacketToAllAround((double)
//x, (double) y, (double) z, 30.0D,
//player.field_71093_bK, (new FXPacket(17,
//(double) x, (double) y, (double)
//z)).getPacket());
}
}
}
@ -176,7 +212,14 @@ public class ItemForceMitts extends ItemTool implements IBreakable, IToolGrafter
}
stack.damageItem(1, player);
world.playSoundEffect((double) x, (double) y, (double) z, "dartcraft:fly", 0.75F, EntityUtils.randomPitch());
world.playSoundEffect(
(double) x,
(double) y,
(double) z,
"dartcraft:fly",
0.75F,
EntityUtils.randomPitch()
);
return true;
}
}

View File

@ -21,12 +21,14 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.common.util.EnumHelper;
public class ItemForcePickaxe extends ItemPickaxe implements IBreakable, IForceConsumer, IForceUpgradable {
public class ItemForcePickaxe
extends ItemPickaxe implements IBreakable, IForceConsumer, IForceUpgradable {
private static int damage = 1;
private static float efficiency = 5.0F;
private static int toolLevel = 10;
public static ToolMaterial material = EnumHelper.addToolMaterial("FORCE", toolLevel, 512, efficiency, (float) damage, 0);
public static ToolMaterial material = EnumHelper.addToolMaterial(
"FORCE", toolLevel, 512, efficiency, (float) damage, 0
);
private IIcon heatPick;
@ -41,7 +43,9 @@ public class ItemForcePickaxe extends ItemPickaxe implements IBreakable, IForceC
stack.setTagCompound(new NBTTagCompound());
}
stack.getTagCompound().setBoolean("active", !stack.getTagCompound().getBoolean("active"));
stack.getTagCompound().setBoolean(
"active", !stack.getTagCompound().getBoolean("active")
);
if (!Dartcraft.proxy.isSimulating(world)) {
if (stack.getTagCompound().getBoolean("active")) {
Dartcraft.proxy.sendChatToPlayer(player, "Area mode activated.");
@ -58,12 +62,10 @@ public class ItemForcePickaxe extends ItemPickaxe implements IBreakable, IForceC
return new ItemStack(DartItems.forceshard);
}
public IIcon getIcon(ItemStack stack, int pass) {
if(stack.hasTagCompound()) {
if (stack.hasTagCompound()) {
NBTTagCompound upgrades = stack.getTagCompound().getCompoundTag("upgrades");
if(upgrades != null && upgrades.hasKey("heat")) {
if (upgrades != null && upgrades.hasKey("heat")) {
return heatPick;
}
}
@ -78,9 +80,9 @@ public class ItemForcePickaxe extends ItemPickaxe implements IBreakable, IForceC
@Override
public EnumRarity getRarity(ItemStack stack) {
if(stack.hasTagCompound() && stack.getTagCompound().hasKey("upgrades")) {
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("upgrades")) {
NBTTagCompound upgrades = stack.getTagCompound().getCompoundTag("upgrades");
if(upgrades.hasKey("Heat")) {
if (upgrades.hasKey("Heat")) {
return EnumRarity.uncommon;
}
}
@ -119,29 +121,35 @@ public class ItemForcePickaxe extends ItemPickaxe implements IBreakable, IForceC
return ForceConsumerUtils.attemptRepair(stack);
}
public int[] validUpgrades()
{
return new int[] { ForceUpgradeManager.HEAT.getID(), ForceUpgradeManager.SPEED.getID(), ForceUpgradeManager.LUCK.getID(), ForceUpgradeManager.TOUCH.getID(), ForceUpgradeManager.STURDY.getID(), ForceUpgradeManager.GRINDING.getID(), ForceUpgradeManager.REPAIR.getID(), ForceUpgradeManager.IMPERVIOUS.getID() };
public int[] validUpgrades() {
return new int[] {
ForceUpgradeManager.HEAT.getID(), ForceUpgradeManager.SPEED.getID(),
ForceUpgradeManager.LUCK.getID(), ForceUpgradeManager.TOUCH.getID(),
ForceUpgradeManager.STURDY.getID(), ForceUpgradeManager.GRINDING.getID(),
ForceUpgradeManager.REPAIR.getID(), ForceUpgradeManager.IMPERVIOUS.getID()
};
}
@Override
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
public boolean
onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
World world = player.worldObj;
Block tempBlock = world.getBlock(x, y, z);
boolean force = false;
if(!this.canHarvestBlock(tempBlock, stack)) {
if (!this.canHarvestBlock(tempBlock, stack)) {
return false;
} else {
if(stack.hasTagCompound() && stack.getTagCompound().getBoolean("active")) {
if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("active")) {
force = true;
}
if(force) {
for(int i = -1; i < 2; ++i) {
for(int j = -1; j < 2; ++j) {
for(int k = -1; k < 2; ++k) {
if(i != 0 || j != 0 || k != 0) {
if(stack == null || stack.getItemDamage() >= stack.getMaxDamage()) {
if (force) {
for (int i = -1; i < 2; ++i) {
for (int j = -1; j < 2; ++j) {
for (int k = -1; k < 2; ++k) {
if (i != 0 || j != 0 || k != 0) {
if (stack == null
|| stack.getItemDamage() >= stack.getMaxDamage()) {
return false;
}
@ -163,8 +171,12 @@ public class ItemForcePickaxe extends ItemPickaxe implements IBreakable, IForceC
World world = player.worldObj;
Block block = world.getBlock(x, y, z);
if (this.canHarvestBlock(block, stack) && block.getBlockHardness(world, x, y, z) > 0F & world.getTileEntity(x, y, z) == null) {
world.getBlock(x, y, z).harvestBlock(world, player, x, y, z, world.getBlockMetadata(x, y, z));
if (this.canHarvestBlock(block, stack)
&& block.getBlockHardness(world, x, y, z) > 0F
& world.getTileEntity(x, y, z) == null) {
world.getBlock(x, y, z).harvestBlock(
world, player, x, y, z, world.getBlockMetadata(x, y, z)
);
world.setBlockToAir(x, y, z);
stack.damageItem(1, player);
}

View File

@ -16,11 +16,12 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.EnumHelper;
public class ItemForceShovel extends ItemSpade implements IBreakable, IForceConsumer {
private static int damage = 1;
private static float efficiency = 5.0F;
private static int toolLevel = 10;
public static ToolMaterial material = EnumHelper.addToolMaterial("FORCE", toolLevel, 512, efficiency, (float) damage, 0);
public static ToolMaterial material = EnumHelper.addToolMaterial(
"FORCE", toolLevel, 512, efficiency, (float) damage, 0
);
public ItemForceShovel() {
super(material);
@ -33,7 +34,9 @@ public class ItemForceShovel extends ItemSpade implements IBreakable, IForceCons
stack.setTagCompound(new NBTTagCompound());
}
stack.getTagCompound().setBoolean("active", !stack.getTagCompound().getBoolean("active"));
stack.getTagCompound().setBoolean(
"active", !stack.getTagCompound().getBoolean("active")
);
if (!Dartcraft.proxy.isSimulating(world)) {
if (stack.getTagCompound().getBoolean("active")) {
Dartcraft.proxy.sendChatToPlayer(player, "Area mode activated.");
@ -77,28 +80,35 @@ public class ItemForceShovel extends ItemSpade implements IBreakable, IForceCons
@Override
public boolean canHarvestBlock(Block block, ItemStack itemStack) {
return block.getMaterial() == Material.clay || block.getMaterial() == Material.craftedSnow || block.getMaterial() == Material.ground || block.getMaterial() == Material.sand || block.getMaterial() == Material.snow || block.getMaterial() == Material.grass;
return block.getMaterial() == Material.clay
|| block.getMaterial() == Material.craftedSnow
|| block.getMaterial() == Material.ground
|| block.getMaterial() == Material.sand
|| block.getMaterial() == Material.snow
|| block.getMaterial() == Material.grass;
}
@Override
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
public boolean
onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
World world = player.worldObj;
Block tempBlock = world.getBlock(x, y, z);
boolean force = false;
if(!this.canHarvestBlock(tempBlock, stack)) {
if (!this.canHarvestBlock(tempBlock, stack)) {
return false;
} else {
if(stack.hasTagCompound() && stack.getTagCompound().getBoolean("active")) {
if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("active")) {
force = true;
}
if(force) {
for(int i = -1; i < 2; ++i) {
for(int j = -1; j < 2; ++j) {
for(int k = -1; k < 2; ++k) {
if(i != 0 || j != 0 || k != 0) {
if(stack == null || stack.getItemDamage() >= stack.getMaxDamage()) {
if (force) {
for (int i = -1; i < 2; ++i) {
for (int j = -1; j < 2; ++j) {
for (int k = -1; k < 2; ++k) {
if (i != 0 || j != 0 || k != 0) {
if (stack == null
|| stack.getItemDamage() >= stack.getMaxDamage()) {
return false;
}
@ -120,8 +130,12 @@ public class ItemForceShovel extends ItemSpade implements IBreakable, IForceCons
World world = player.worldObj;
Block block = world.getBlock(x, y, z);
if (this.canHarvestBlock(block, stack) && block.getBlockHardness(world, x, y, z) > 0F & world.getTileEntity(x, y, z) == null) {
world.getBlock(x, y, z).harvestBlock(world, player, x, y, z, world.getBlockMetadata(x, y, z));
if (this.canHarvestBlock(block, stack)
&& block.getBlockHardness(world, x, y, z) > 0F
& world.getTileEntity(x, y, z) == null) {
world.getBlock(x, y, z).harvestBlock(
world, player, x, y, z, world.getBlockMetadata(x, y, z)
);
world.setBlockToAir(x, y, z);
stack.damageItem(1, player);
}

View File

@ -38,8 +38,13 @@ public abstract class DartPacket implements IMessage {
this.receiver += buf.readChar();
}
if (buf.readBoolean())
this
.point = new NetworkRegistry.TargetPoint(buf.readInt(), buf.readDouble(), buf.readDouble(), buf.readDouble(), buf.readDouble());
this.point = new NetworkRegistry.TargetPoint(
buf.readInt(),
buf.readDouble(),
buf.readDouble(),
buf.readDouble(),
buf.readDouble()
);
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -40,7 +40,11 @@ public class PacketClipButton extends DartPacket implements IMessage {
public IMessage onMessage(PacketClipButton packet, MessageContext ctx) {
EntityPlayer player = EntityUtils.getPlayerByName(packet.getReceiver());
if (player != null) {
ContainerClipboard clipboard = (player.openContainer != null && player.openContainer instanceof ContainerClipboard) ? (ContainerClipboard)player.openContainer : null;
ContainerClipboard clipboard
= (player.openContainer != null
&& player.openContainer instanceof ContainerClipboard)
? (ContainerClipboard) player.openContainer
: null;
if (clipboard != null)
switch (packet.button) {
case 0:

View File

@ -24,7 +24,6 @@ import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
public class ClientProxy extends CommonProxy {
public static RenderTileForceEngine engineRender;
public boolean isSimulating(World world) {
@ -33,24 +32,49 @@ public class ClientProxy extends CommonProxy {
public void bindTexture(String texture) {
if (texture != null)
getClientInstance().getTextureManager().bindTexture(new ResourceLocation(Dartcraft.MODID, texture));
getClientInstance().getTextureManager().bindTexture(
new ResourceLocation(Dartcraft.MODID, texture)
);
}
public void init() {
super.init();
MinecraftForgeClient.registerItemRenderer(DartItems.forceflask, RenderItemForceFlask.instance);
MinecraftForgeClient.registerItemRenderer(DartItems.entitybottle, RenderItemForceFlask.instance);
MinecraftForgeClient.registerItemRenderer(
DartItems.forceflask, RenderItemForceFlask.instance
);
MinecraftForgeClient.registerItemRenderer(
DartItems.entitybottle, RenderItemForceFlask.instance
);
RenderEntityBottle bottleRenderer = new RenderEntityBottle();
RenderingRegistry.registerEntityRenderingHandler(EntityBottle.class, bottleRenderer);
RenderingRegistry.registerEntityRenderingHandler(EntityFlyingFlask.class, bottleRenderer);
RenderingRegistry.registerEntityRenderingHandler(EntityColdChicken.class, new RenderColdAnimal(new ModelChicken(), 0.6f, "textures/entity/coldChicken.png"));
RenderingRegistry.registerEntityRenderingHandler(EntityColdCow.class, new RenderColdAnimal(new ModelCow(), 0.6f, "textures/entity/coldCow.png"));
RenderingRegistry.registerEntityRenderingHandler(EntityColdPig.class, new RenderColdAnimal(new ModelPig(), 0.6f, "textures/entity/coldPig.png"));
RenderingRegistry.registerEntityRenderingHandler(
EntityBottle.class, bottleRenderer
);
RenderingRegistry.registerEntityRenderingHandler(
EntityFlyingFlask.class, bottleRenderer
);
RenderingRegistry.registerEntityRenderingHandler(
EntityColdChicken.class,
new RenderColdAnimal(
new ModelChicken(), 0.6f, "textures/entity/coldChicken.png"
)
);
RenderingRegistry.registerEntityRenderingHandler(
EntityColdCow.class,
new RenderColdAnimal(new ModelCow(), 0.6f, "textures/entity/coldCow.png")
);
RenderingRegistry.registerEntityRenderingHandler(
EntityColdPig.class,
new RenderColdAnimal(new ModelPig(), 0.6f, "textures/entity/coldPig.png")
);
Config.powerOreRenderID = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new PowerOreRenderer());
engineRender = new RenderTileForceEngine();
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityForceEngine.class, engineRender);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(DartBlocks.engine), new RenderItemEngine());
ClientRegistry.bindTileEntitySpecialRenderer(
TileEntityForceEngine.class, engineRender
);
MinecraftForgeClient.registerItemRenderer(
Item.getItemFromBlock(DartBlocks.engine), new RenderItemEngine()
);
}
public void sendPacketToServer(DartPacket packet) {
@ -60,5 +84,4 @@ public class ClientProxy extends CommonProxy {
e.printStackTrace();
}
}
}

View File

@ -14,7 +14,6 @@ import net.minecraft.world.World;
import java.util.Random;
public class CommonProxy {
public static Random rand = new Random();
public void sendChatToPlayer(EntityPlayer player, String message) {
@ -29,8 +28,7 @@ public class CommonProxy {
return FMLClientHandler.instance().getClient();
}
public void bindTexture(String texture) {
}
public void bindTexture(String texture) {}
public void init() {
ForceUpgradeManager.load();
@ -38,5 +36,4 @@ public class CommonProxy {
}
public void sendPacketToServer(DartPacket packet) {}
}

View File

@ -5,7 +5,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class DartcraftTab extends CreativeTabs {
public DartcraftTab() {
super("dartcraft");
}

View File

@ -22,7 +22,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
public class TileEntityForceEngine extends TileEntity implements IFluidHandler, IInventory, IEnergyProvider { //TODO Fix GUI
public class TileEntityForceEngine extends TileEntity
implements IFluidHandler, IInventory, IEnergyProvider { //TODO Fix GUI
public static final int MAX_STORED = 50000;
@ -58,18 +59,16 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
public FluidTank throttleTank;
public TileEntityForceEngine() {
this.fuelTank = new FluidTank(10000);
this.throttleTank = new FluidTank(10000);
this.fuelLossCycle = this.throttleLossCycle = 0;
this.liquidInventory = new InventoryBasic("forceEngine.stacks", false, 2);
this.liquidInventory.setInventorySlotContents(0, (ItemStack)null);
this.liquidInventory.setInventorySlotContents(1, (ItemStack)null);
this.liquidInventory.setInventorySlotContents(0, (ItemStack) null);
this.liquidInventory.setInventorySlotContents(1, (ItemStack) null);
this.facing = ForgeDirection.UP;
}
public ForgeDirection getFacing() {
return this.facing;
}
@ -84,13 +83,18 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
}
public boolean rotateBlock() {
for(int i = this.facing.ordinal() + 1; i < this.facing.ordinal() + 6; ++i) {
for (int i = this.facing.ordinal() + 1; i < this.facing.ordinal() + 6; ++i) {
ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[i % 6];
TileEntity tile = this.worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
if(tile instanceof IEnergyReceiver && ((IEnergyReceiver) tile).canConnectEnergy(dir.getOpposite())) {
TileEntity tile = this.worldObj.getTileEntity(
xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ
);
if (tile instanceof IEnergyReceiver
&& ((IEnergyReceiver) tile).canConnectEnergy(dir.getOpposite())) {
this.facing = dir;
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
this.worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
this.worldObj.notifyBlocksOfNeighborChange(
xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)
);
return true;
}
}
@ -103,8 +107,10 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
}
protected boolean canCycle() {
TileEntity tile = this.worldObj.getTileEntity(xCoord + facing.offsetX, yCoord + facing.offsetY, zCoord + facing.offsetZ);
if(tile instanceof IEnergyReceiver) {
TileEntity tile = this.worldObj.getTileEntity(
xCoord + facing.offsetX, yCoord + facing.offsetY, zCoord + facing.offsetZ
);
if (tile instanceof IEnergyReceiver) {
this.canCycle = true;
} else {
this.canCycle = false;
@ -118,20 +124,22 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
}
public float getEnergyPerProcess() {
if(this.fuelTank.getFluid() == null) {
if (this.fuelTank.getFluid() == null) {
return 0.0F;
} else {
EngineLiquid fuel = ForceEngineLiquids.getEngineLiquid(this.fuelTank.getFluid());
EngineLiquid fuel
= ForceEngineLiquids.getEngineLiquid(this.fuelTank.getFluid());
EngineLiquid throttle = null;
if(this.throttleTank.getFluid() != null) {
throttle = ForceEngineLiquids.getEngineLiquid(this.throttleTank.getFluid());
if (this.throttleTank.getFluid() != null) {
throttle
= ForceEngineLiquids.getEngineLiquid(this.throttleTank.getFluid());
}
if(fuel == null) {
if (fuel == null) {
return 0.0F;
} else {
float energy = fuel.getModifier();
if(throttle != null) {
if (throttle != null) {
energy *= throttle.getModifier();
}
@ -141,40 +149,46 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
}
private void doLoss() {
if(this.fuelTank.getFluid() != null) {
EngineLiquid fuel = ForceEngineLiquids.getEngineLiquid(this.fuelTank.getFluid());
if (this.fuelTank.getFluid() != null) {
EngineLiquid fuel
= ForceEngineLiquids.getEngineLiquid(this.fuelTank.getFluid());
EngineLiquid throttle = null;
if(this.throttleTank.getFluid() != null) {
throttle = ForceEngineLiquids.getEngineLiquid(this.throttleTank.getFluid());
if (this.throttleTank.getFluid() != null) {
throttle
= ForceEngineLiquids.getEngineLiquid(this.throttleTank.getFluid());
}
FluidStack var10000;
if(fuel != null) {
if (fuel != null) {
++this.fuelLossCycle;
if(this.fuelLossCycle >= fuel.getBurnTime() / 1000) {
if (this.fuelLossCycle >= fuel.getBurnTime() / 1000) {
var10000 = this.fuelTank.getFluid();
var10000.amount -= 1000 / fuel.getBurnTime() > 0?1000 / fuel.getBurnTime():1;
var10000.amount
-= 1000 / fuel.getBurnTime() > 0 ? 1000 / fuel.getBurnTime() : 1;
this.fuelLossCycle = 0;
}
}
if(throttle != null) {
if (throttle != null) {
++this.throttleLossCycle;
if(this.throttleLossCycle >= throttle.getBurnTime() / 1000) {
if (this.throttleLossCycle >= throttle.getBurnTime() / 1000) {
var10000 = this.throttleTank.getFluid();
var10000.amount -= 1000 / throttle.getBurnTime() > 0?1000 / throttle.getBurnTime():1;
var10000.amount -= 1000 / throttle.getBurnTime() > 0
? 1000 / throttle.getBurnTime()
: 1;
this.throttleLossCycle = 0;
}
}
if(this.fuelTank.getFluid() != null && this.fuelTank.getFluid().amount <= 0) {
if (this.fuelTank.getFluid() != null
&& this.fuelTank.getFluid().amount <= 0) {
this.fuelTank.setFluid(null);
}
if(this.throttleTank.getFluid() != null && this.throttleTank.getFluid().amount <= 0) {
if (this.throttleTank.getFluid() != null
&& this.throttleTank.getFluid().amount <= 0) {
this.throttleTank.setFluid(null);
}
}
}
@ -183,57 +197,85 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
}
protected void transferEnergy() { //TODO better energy transfer
TileEntity tile = this.worldObj.getTileEntity(xCoord + facing.offsetX, yCoord + facing.offsetY, zCoord + facing.offsetZ);
if(tile instanceof IEnergyReceiver && ((IEnergyReceiver) tile).canConnectEnergy(facing.getOpposite())) {
TileEntity tile = this.worldObj.getTileEntity(
xCoord + facing.offsetX, yCoord + facing.offsetY, zCoord + facing.offsetZ
);
if (tile instanceof IEnergyReceiver
&& ((IEnergyReceiver) tile).canConnectEnergy(facing.getOpposite())) {
int energy = (int) this.getEnergyPerProcess() * 200;
((IEnergyReceiver) tile).receiveEnergy(facing.getOpposite(), energy, false);
}
}
public void updateEntity() {
if(!Dartcraft.proxy.isSimulating(worldObj)) {
if(this.cycleProgress > 0.0F || this.isActive && this.canCycle) {
if (!Dartcraft.proxy.isSimulating(worldObj)) {
if (this.cycleProgress > 0.0F || this.isActive && this.canCycle) {
this.cycleProgress += 0.04F;
if(this.cycleProgress >= 1.0F) {
if (this.cycleProgress >= 1.0F) {
this.cycleProgress = 0.0F;
}
}
} else {
FluidStack curActive;
if(this.liquidInventory.getStackInSlot(0) != null) {
curActive = FluidContainerRegistry.getFluidForFilledItem(this.liquidInventory.getStackInSlot(0));
if (this.liquidInventory.getStackInSlot(0) != null) {
curActive = FluidContainerRegistry.getFluidForFilledItem(
this.liquidInventory.getStackInSlot(0)
);
Fluid curCycle = FluidRegistry.getFluid("liquidforce");
if(curActive != null) {
if (curActive != null) {
EngineLiquid temp = ForceEngineLiquids.getEngineLiquid(curActive);
if(temp != null && (this.fuelTank.getFluid() == null || this.fuelTank.getFluid().isFluidEqual(curActive)) && (this.fuelTank.getFluid() == null || 10000 >= this.fuelTank.getFluid().amount + curActive.amount)) {
if (temp != null
&& (this.fuelTank.getFluid() == null
|| this.fuelTank.getFluid().isFluidEqual(curActive))
&& (this.fuelTank.getFluid() == null
|| 10000 >= this.fuelTank.getFluid().amount + curActive.amount
)) {
this.fuelTank.fill(curActive, true);
ItemStack temp1 = this.liquidInventory.getStackInSlot(0);
if(temp1.stackSize == 1 && temp1.getItem().hasContainerItem()) {
this.liquidInventory.setInventorySlotContents(0, temp1.getItem().getContainerItem(temp1));
if (temp1.stackSize == 1 && temp1.getItem().hasContainerItem()) {
this.liquidInventory.setInventorySlotContents(
0, temp1.getItem().getContainerItem(temp1)
);
} else {
this.liquidInventory.decrStackSize(0, 1);
}
}
}
if(this.liquidInventory.getStackInSlot(0) != null && this.liquidInventory.getStackInSlot(0).getItem() == DartItems.forcegem && curCycle != null && (this.fuelTank.getFluid() == null || 10000 >= this.fuelTank.getFluid().amount + (int)(1000.0F * Config.gemValue))) {
this.fuelTank.fill(new FluidStack(curCycle, (int)(1000.0F * Config.gemValue)), true);
if (this.liquidInventory.getStackInSlot(0) != null
&& this.liquidInventory.getStackInSlot(0).getItem()
== DartItems.forcegem
&& curCycle != null
&& (this.fuelTank.getFluid() == null
|| 10000 >= this.fuelTank.getFluid().amount
+ (int) (1000.0F * Config.gemValue))) {
this.fuelTank.fill(
new FluidStack(curCycle, (int) (1000.0F * Config.gemValue)), true
);
this.liquidInventory.decrStackSize(0, 1);
}
}
if(this.liquidInventory.getStackInSlot(1) != null) {
curActive = FluidContainerRegistry.getFluidForFilledItem(this.liquidInventory.getStackInSlot(1));
if(curActive != null) {
EngineLiquid curCycle1 = ForceEngineLiquids.getEngineLiquid(curActive);
if(curCycle1 != null && (this.throttleTank.getFluid() == null || this.throttleTank.getFluid().isFluidEqual(curActive)) && (this.throttleTank.getFluid() == null || 10000 >= this.throttleTank.getFluid().amount + curActive.amount)) {
if (this.liquidInventory.getStackInSlot(1) != null) {
curActive = FluidContainerRegistry.getFluidForFilledItem(
this.liquidInventory.getStackInSlot(1)
);
if (curActive != null) {
EngineLiquid curCycle1
= ForceEngineLiquids.getEngineLiquid(curActive);
if (curCycle1 != null
&& (this.throttleTank.getFluid() == null
|| this.throttleTank.getFluid().isFluidEqual(curActive))
&& (this.throttleTank.getFluid() == null
|| 10000 >= this.throttleTank.getFluid().amount
+ curActive.amount)) {
this.throttleTank.fill(curActive, true);
ItemStack temp2 = this.liquidInventory.getStackInSlot(1);
if(temp2.stackSize == 1 && temp2.getItem().hasContainerItem()) {
this.liquidInventory.setInventorySlotContents(1, temp2.getItem().getContainerItem(temp2));
if (temp2.stackSize == 1 && temp2.getItem().hasContainerItem()) {
this.liquidInventory.setInventorySlotContents(
1, temp2.getItem().getContainerItem(temp2)
);
} else {
this.liquidInventory.decrStackSize(1, 1);
}
@ -241,19 +283,20 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
}
}
if(this.cycleProgress > 0.0F || this.isActive && this.canCycle) {
if (this.cycleProgress > 0.0F || this.isActive && this.canCycle) {
this.cycleProgress += 0.04F;
if(this.cycleProgress >= 1.0F) {
if (this.cycleProgress >= 1.0F) {
this.cycleProgress = 0.0F;
this.stageCycle = false;
} else if((double)this.cycleProgress >= 0.5D && !this.stageCycle) {
} else if ((double) this.cycleProgress >= 0.5D && !this.stageCycle) {
this.transferEnergy();
this.stageCycle = true;
}
}
if(this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && this.canCycle()) {
if(this.canProcess()) {
if (this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)
&& this.canCycle()) {
if (this.canProcess()) {
this.isActive = true;
this.processActive();
} else {
@ -272,53 +315,68 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
this.isActive = data.getBoolean("active");
this.fuelRF = data.getFloat("fuelRF");
this.canCycle = data.getBoolean("cycle");
if(data.hasKey("fuel")) {
this.fuelTank.setFluid(FluidStack.loadFluidStackFromNBT(data.getCompoundTag("fuel")));
if (data.hasKey("fuel")) {
this.fuelTank.setFluid(
FluidStack.loadFluidStackFromNBT(data.getCompoundTag("fuel"))
);
}
if(data.hasKey("throttle")) {
this.throttleTank.setFluid(FluidStack.loadFluidStackFromNBT(data.getCompoundTag("throttle")));
if (data.hasKey("throttle")) {
this.throttleTank.setFluid(
FluidStack.loadFluidStackFromNBT(data.getCompoundTag("throttle"))
);
}
if(data.hasKey("fuelSlot")) {
this.liquidInventory.setInventorySlotContents(0, ItemStack.loadItemStackFromNBT(data.getCompoundTag("fuelSlot")));
if (data.hasKey("fuelSlot")) {
this.liquidInventory.setInventorySlotContents(
0, ItemStack.loadItemStackFromNBT(data.getCompoundTag("fuelSlot"))
);
} else {
this.liquidInventory.setInventorySlotContents(0, (ItemStack)null);
this.liquidInventory.setInventorySlotContents(0, (ItemStack) null);
}
if(data.hasKey("throttleSlot")) {
this.liquidInventory.setInventorySlotContents(1, ItemStack.loadItemStackFromNBT(data.getCompoundTag("throttleSlot")));
if (data.hasKey("throttleSlot")) {
this.liquidInventory.setInventorySlotContents(
1, ItemStack.loadItemStackFromNBT(data.getCompoundTag("throttleSlot"))
);
} else {
this.liquidInventory.setInventorySlotContents(1, (ItemStack)null);
this.liquidInventory.setInventorySlotContents(1, (ItemStack) null);
}
}
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
data.setByte("facing", (byte)this.facing.ordinal());
data.setByte("facing", (byte) this.facing.ordinal());
data.setBoolean("active", this.isActive);
data.setFloat("fuelRF", this.fuelRF);
data.setBoolean("cycle", this.canCycle);
if(this.fuelTank.getFluid() != null) {
data.setTag("fuel", this.fuelTank.getFluid().writeToNBT(new NBTTagCompound()));
if (this.fuelTank.getFluid() != null) {
data.setTag(
"fuel", this.fuelTank.getFluid().writeToNBT(new NBTTagCompound())
);
}
if(this.throttleTank.getFluid() != null) {
data.setTag("throttle", this.throttleTank.getFluid().writeToNBT(new NBTTagCompound()));
if (this.throttleTank.getFluid() != null) {
data.setTag(
"throttle", this.throttleTank.getFluid().writeToNBT(new NBTTagCompound())
);
}
if(this.liquidInventory.getStackInSlot(0) != null) {
data.setTag("fuelSlot", this.liquidInventory.getStackInSlot(0).writeToNBT(new NBTTagCompound()));
if (this.liquidInventory.getStackInSlot(0) != null) {
data.setTag(
"fuelSlot",
this.liquidInventory.getStackInSlot(0).writeToNBT(new NBTTagCompound())
);
}
if(this.liquidInventory.getStackInSlot(1) != null) {
data.setTag("throttleSlot", this.liquidInventory.getStackInSlot(1).writeToNBT(new NBTTagCompound()));
if (this.liquidInventory.getStackInSlot(1) != null) {
data.setTag(
"throttleSlot",
this.liquidInventory.getStackInSlot(1).writeToNBT(new NBTTagCompound())
);
}
}
@Override
public int extractEnergy(ForgeDirection var1, int var2, boolean var3) {
return 0;
@ -396,11 +454,15 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
@Override
public boolean isItemValidForSlot(int i, ItemStack stack) {
switch(i) {
switch (i) {
case 0:
return ForceEngineLiquids.isFuel(FluidContainerRegistry.getFluidForFilledItem(stack));
return ForceEngineLiquids.isFuel(
FluidContainerRegistry.getFluidForFilledItem(stack)
);
case 1:
return ForceEngineLiquids.isThrottle(FluidContainerRegistry.getFluidForFilledItem(stack));
return ForceEngineLiquids.isThrottle(
FluidContainerRegistry.getFluidForFilledItem(stack)
);
default:
return false;
}
@ -409,10 +471,10 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
int filled;
if(ForceEngineLiquids.isFuel(resource)) {
if (ForceEngineLiquids.isFuel(resource)) {
filled = this.fuelTank.fill(resource, doFill);
return filled;
} else if(ForceEngineLiquids.isThrottle(resource)) {
} else if (ForceEngineLiquids.isThrottle(resource)) {
filled = this.throttleTank.fill(resource, doFill);
return filled;
} else {
@ -432,7 +494,8 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return (from != null && fluid != null) && this.fill(from, new FluidStack(fluid, 1), false) > 0;
return (from != null && fluid != null)
&& this.fill(from, new FluidStack(fluid, 1), false) > 0;
}
@Override
@ -442,7 +505,8 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return new FluidTankInfo[]{this.fuelTank.getInfo(), this.throttleTank.getInfo()};
return new FluidTankInfo[] { this.fuelTank.getInfo(),
this.throttleTank.getInfo() };
}
public Packet getDescriptionPacket() {
@ -452,12 +516,12 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
}
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
if(pkt != null && pkt.func_148857_g() != null) {
if (pkt != null && pkt.func_148857_g() != null) {
this.readFromNBT(pkt.func_148857_g());
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); //TODO Lighting
//worldObj.updateAllLightTypes(this.field_70329_l, this.field_70330_m, this.field_70327_n);
//worldObj.updateAllLightTypes(this.field_70329_l, this.field_70330_m,
//this.field_70327_n);
}
}
public void sendGuiNetworkData(Container container, ICrafting craft) {
@ -467,12 +531,12 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
byte fuelMeta = 0;
int fuelID = 0;
int fuelAmount = 0;
if(this.fuelTank.getFluid() != null) {
if (this.fuelTank.getFluid() != null) {
fuelID = this.fuelTank.getFluid().getFluidID();
fuelAmount = this.fuelTank.getFluid().amount;
}
if(this.throttleTank.getFluid() != null) {
if (this.throttleTank.getFluid() != null) {
throttleID = this.throttleTank.getFluid().getFluidID();
throttleAmount = this.throttleTank.getFluid().amount;
}
@ -483,50 +547,57 @@ public class TileEntityForceEngine extends TileEntity implements IFluidHandler,
craft.sendProgressBarUpdate(container, 3, throttleID);
craft.sendProgressBarUpdate(container, 4, throttleMeta);
craft.sendProgressBarUpdate(container, 5, throttleAmount);
if(craft instanceof EntityPlayerMP && Dartcraft.proxy.isSimulating(worldObj)) {
((EntityPlayerMP) craft).playerNetServerHandler.sendPacket(getDescriptionPacket());
if (craft instanceof EntityPlayerMP && Dartcraft.proxy.isSimulating(worldObj)) {
((EntityPlayerMP) craft)
.playerNetServerHandler.sendPacket(getDescriptionPacket());
}
}
public void receiveGuiNetworkData(int i, int j) {
FluidStack tempStack = this.fuelTank.getFluid();
FluidStack tempStack2 = this.throttleTank.getFluid();
switch(i) {
switch (i) {
case 0:
if(this.fuelTank.getFluid() != null) {
this.fuelTank.setFluid(new FluidStack(j, tempStack.amount, tempStack.tag));
if (this.fuelTank.getFluid() != null) {
this.fuelTank.setFluid(
new FluidStack(j, tempStack.amount, tempStack.tag)
);
} else if (j > 0) {
this.fuelTank.setFluid(new FluidStack(j, 0));
}
break;
case 1:
if(this.fuelTank.getFluid() != null) {
this.fuelTank.setFluid(new FluidStack(tempStack.getFluidID(), tempStack.amount, (NBTTagCompound)null));
if (this.fuelTank.getFluid() != null) {
this.fuelTank.setFluid(new FluidStack(
tempStack.getFluidID(), tempStack.amount, (NBTTagCompound) null
));
}
break;
case 2:
if(this.fuelTank.getFluid() != null) {
if (this.fuelTank.getFluid() != null) {
this.fuelTank.getFluid().amount = j;
}
break;
case 3:
if(this.throttleTank.getFluid() != null) {
this.throttleTank.setFluid(new FluidStack(j, tempStack2.amount, tempStack2.tag));
if (this.throttleTank.getFluid() != null) {
this.throttleTank.setFluid(
new FluidStack(j, tempStack2.amount, tempStack2.tag)
);
} else if (j > 0) {
this.throttleTank.setFluid(new FluidStack(j, 0));
}
break;
case 4:
if(this.throttleTank.getFluid() != null) {
this.throttleTank.setFluid(new FluidStack(tempStack2.getFluidID(), tempStack2.amount, (NBTTagCompound)null));
if (this.throttleTank.getFluid() != null) {
this.throttleTank.setFluid(new FluidStack(
tempStack2.getFluidID(), tempStack2.amount, (NBTTagCompound) null
));
}
break;
case 5:
if(this.throttleTank.getFluid() != null) {
if (this.throttleTank.getFluid() != null) {
this.throttleTank.getFluid().amount = j;
}
}
}
}

View File

@ -1,5 +1,6 @@
package ley.modding.dartcraft.util;
import java.awt.Color;
import buildcraft.api.tools.IToolWrench;
import ley.modding.dartcraft.Dartcraft;
import ley.modding.dartcraft.proxy.CommonProxy;
@ -15,9 +16,8 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
public class DartUtils {
public static boolean isHoldingWrench(EntityPlayer player) {
if(player.getCurrentEquippedItem() == null) {
if (player.getCurrentEquippedItem() == null) {
return false;
} else {
Item equipped = player.getCurrentEquippedItem().getItem();
@ -25,14 +25,19 @@ public class DartUtils {
}
}
public static boolean fillTankWithContainer(IFluidHandler theTile, EntityPlayer player) {
public static boolean
fillTankWithContainer(IFluidHandler theTile, EntityPlayer player) {
ItemStack theContainer = player.getCurrentEquippedItem();
FluidStack theLiquid = FluidContainerRegistry.getFluidForFilledItem(theContainer);
if(theLiquid != null && (theTile.fill(ForgeDirection.UNKNOWN, theLiquid, false) == theLiquid.amount || player.capabilities.isCreativeMode)) {
if (theLiquid != null
&& (theTile.fill(ForgeDirection.UNKNOWN, theLiquid, false) == theLiquid.amount
|| player.capabilities.isCreativeMode)) {
theTile.fill(ForgeDirection.UNKNOWN, theLiquid, true);
ItemStack returnStack = consumeItem(theContainer);
if(!player.capabilities.isCreativeMode) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, returnStack);
if (!player.capabilities.isCreativeMode) {
player.inventory.setInventorySlotContents(
player.inventory.currentItem, returnStack
);
}
return true;
@ -42,42 +47,81 @@ public class DartUtils {
}
public static ItemStack consumeItem(ItemStack theStack) {
if(theStack.stackSize == 1) {
return theStack.getItem().hasContainerItem()?theStack.getItem().getContainerItem(theStack):null;
if (theStack.stackSize == 1) {
return theStack.getItem().hasContainerItem()
? theStack.getItem().getContainerItem(theStack)
: null;
} else {
theStack.splitStack(1);
return theStack;
}
}
public static void dropItem(ItemStack stack, World world, double x, double y, double z) {
if(stack != null && world != null && Dartcraft.proxy.isSimulating(world)) {
public static void
dropItem(ItemStack stack, World world, double x, double y, double z) {
if (stack != null && world != null && Dartcraft.proxy.isSimulating(world)) {
float xRand = CommonProxy.rand.nextFloat() * 0.2F + 0.1F;
float yRand = CommonProxy.rand.nextFloat() * 0.8F + 0.1F;
float zRand = CommonProxy.rand.nextFloat() * 0.2F + 0.1F;
while(stack.stackSize > 0) {
while (stack.stackSize > 0) {
int randInt = CommonProxy.rand.nextInt(21) + 10;
if(randInt > stack.stackSize) {
if (randInt > stack.stackSize) {
randInt = stack.stackSize;
}
stack.stackSize -= randInt;
EntityItem droppedItem = new EntityItem(world, (double)((float)x + xRand), (double)((float)y + yRand), (double)((float)z + zRand), new ItemStack(stack.getItem(), randInt, stack.getItemDamage()));
if(stack.hasTagCompound()) {
droppedItem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
EntityItem droppedItem = new EntityItem(
world,
(double) ((float) x + xRand),
(double) ((float) y + yRand),
(double) ((float) z + zRand),
new ItemStack(stack.getItem(), randInt, stack.getItemDamage())
);
if (stack.hasTagCompound()) {
droppedItem.getEntityItem().setTagCompound(
(NBTTagCompound) stack.getTagCompound().copy()
);
}
float modifier = 0.025F;
CommonProxy var10001 = Dartcraft.proxy;
droppedItem.motionX = (double)((float)CommonProxy.rand.nextGaussian() * modifier);
droppedItem.motionY = (double)((float)CommonProxy.rand.nextGaussian() * modifier + 0.2F);
droppedItem.motionZ = (double)((float)CommonProxy.rand.nextGaussian() * modifier);
droppedItem.motionX
= (double) ((float) CommonProxy.rand.nextGaussian() * modifier);
droppedItem.motionY
= (double) ((float) CommonProxy.rand.nextGaussian() * modifier + 0.2F
);
droppedItem.motionZ
= (double) ((float) CommonProxy.rand.nextGaussian() * modifier);
droppedItem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(droppedItem);
}
}
}
public static float randomPitch() {
return CommonProxy.rand.nextFloat() * 0.25F + 0.85F;
}
public static int getMcColor(int color) {
int[] lookup = new int[] {
0x333333,
Color.red.getRGB(),
Color.green.getRGB(),
0x6e5334,
Color.blue.getRGB(),
0x6b47b8,
Color.cyan.getRGB(),
Color.lightGray.getRGB(),
Color.gray.getRGB(),
Color.pink.getRGB(),
0x9ed843,
Color.yellow.getRGB(),
0x51a8f4,
Color.magenta.getRGB(),
Color.orange.getRGB(),
Color.white.getRGB(),
};
return color > 0 && color < lookup.length ? lookup[color] : 0;
}
}

View File

@ -15,13 +15,16 @@ import net.minecraft.world.WorldServer;
import java.lang.reflect.Constructor;
public class EntityUtils {
public static NBTTagCompound getModComp(Entity entity) {
if (entity == null || entity.getEntityData() == null)
return new NBTTagCompound();
NBTTagCompound comp = entity.getEntityData().hasKey(Dartcraft.MODID) ? entity.getEntityData().getCompoundTag(Dartcraft.MODID) : null;
NBTTagCompound comp = entity.getEntityData().hasKey(Dartcraft.MODID)
? entity.getEntityData().getCompoundTag(Dartcraft.MODID)
: null;
if (comp == null) {
entity.getEntityData().setTag(Dartcraft.MODID, (NBTBase)new NBTTagCompound());
entity.getEntityData().setTag(
Dartcraft.MODID, (NBTBase) new NBTTagCompound()
);
comp = entity.getEntityData().getCompoundTag(Dartcraft.MODID);
}
return comp;
@ -71,7 +74,8 @@ public class EntityUtils {
try {
Class entityClass = (Class) EntityList.stringToClassMapping.get(name);
if (entityClass != null) {
Constructor<Entity> constructor = entityClass.getConstructor(new Class[] { World.class });
Constructor<Entity> constructor
= entityClass.getConstructor(new Class[] { World.class });
Entity entity = constructor.newInstance(new Object[] { null });
return entity;
}
@ -99,5 +103,4 @@ public class EntityUtils {
}
return player;
}
}

View File

@ -0,0 +1,650 @@
package ley.modding.dartcraft.util;
import java.awt.Color;
import java.util.Random;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ley.modding.dartcraft.Dartcraft;
import ley.modding.dartcraft.proxy.CommonProxy;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFireworkStarterFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
public class FXUtils {
public static Random rand = new Random();
@SideOnly(Side.CLIENT)
public static void bindGLColor(int color) {
byte e = (byte) (color << 24);
byte green = (byte) (color << 16);
byte blue = (byte) (color << 8);
GL11.glColor4f((float) e, (float) green, (float) blue, -1.0F);
}
public static void
makeEnderEffects(World world, double x, double y, double z, int number) {
if (!Dartcraft.proxy.isSimulating(world)) {
float modifier = 0.1F;
for (int i = 0; i < number; ++i) {
double var10002 = x + world.rand.nextDouble() - world.rand.nextDouble();
double var10003 = y + world.rand.nextDouble() - world.rand.nextDouble();
double var10004 = z + world.rand.nextDouble() - world.rand.nextDouble();
double var10
= (double) ((CommonProxy.rand.nextFloat() * 2.0F - 1.0F) * modifier);
double var10006 = (double) modifier;
world.spawnParticle(
"portal",
var10002,
var10003,
var10004,
var10,
var10006,
(double) ((CommonProxy.rand.nextFloat() * 2.0F - 1.0F) * modifier)
);
}
}
}
public static void
makeHeatEffects(World world, int x, int y, int z, int number, int area) {
makeHeatEffects(
world,
(double) x + 0.5D,
(double) y + 1.0D,
(double) z + 0.5D,
number,
area,
1
);
}
public static void
makeHeatEffects(World world, double x, double y, double z, int number, int area) {
makeHeatEffects(world, x, y, z, number, area, 0);
}
public static void makeHeatEffects(
World world, double x, double y, double z, int number, int area, int type
) {
if (!Dartcraft.proxy.isSimulating(world)) {
float modifier = 0.1F;
int i;
if (area > 0) {
for (i = -area; i < area + 1; ++i) {
for (int velX = -area; velX < area + 1; ++velX) {
for (int k = -area; k < area + 1; ++k) {
for (int velZ = 0; velZ < number; ++velZ) {
double velX1
= (double) ((CommonProxy.rand.nextFloat() * 2.0F
- 1.0F)
* modifier);
double velZ1
= (double) ((CommonProxy.rand.nextFloat() * 2.0F
- 1.0F)
* modifier);
double dist1 = 1.0D;
if (type == 1) {
velX1 = 0.0D;
velZ1 = 0.0D;
modifier = (float) ((double) modifier * 0.5D);
dist1 *= 0.5D;
}
world.spawnParticle(
"flame",
x + world.rand.nextDouble() * dist1
- world.rand.nextDouble() * dist1,
y + world.rand.nextDouble() * dist1
- world.rand.nextDouble() * dist1,
z + world.rand.nextDouble() * dist1
- world.rand.nextDouble() * dist1,
velX1,
(double) modifier,
velZ1
);
}
}
}
}
} else {
for (i = 0; i < number; ++i) {
double var21 = (double) ((CommonProxy.rand.nextFloat() * 2.0F - 1.0F)
* modifier);
double var22 = (double) ((CommonProxy.rand.nextFloat() * 2.0F - 1.0F)
* modifier);
double dist = 1.0D;
if (type == 1) {
var21 = 0.0D;
var22 = 0.0D;
modifier = (float) ((double) modifier * 0.25D);
dist *= 0.5D;
}
world.spawnParticle(
"flame",
x + world.rand.nextDouble() * dist
- world.rand.nextDouble() * dist,
y + world.rand.nextDouble() * dist
- world.rand.nextDouble() * dist,
z + world.rand.nextDouble() * dist
- world.rand.nextDouble() * dist,
var21,
(double) modifier,
var22
);
}
}
}
}
public static void makeEnderEffects(
Entity entity, double prevX, double prevY, double prevZ, int number, boolean sound
) {
World world = entity.worldObj;
if (!Dartcraft.proxy.isSimulating(world)) {
for (int i = 0; i < number; ++i) {
double var19 = (double) i / ((double) number - 1.0D);
CommonProxy var10000 = Dartcraft.proxy;
float var21 = (CommonProxy.rand.nextFloat() - 0.5F) * 0.2F;
var10000 = Dartcraft.proxy;
float var22 = (CommonProxy.rand.nextFloat() - 0.5F) * 0.2F;
var10000 = Dartcraft.proxy;
float var23 = (CommonProxy.rand.nextFloat() - 0.5F) * 0.2F;
double var221 = prevX + (entity.posX - prevX) * var19;
CommonProxy var10001 = Dartcraft.proxy;
double var24 = var221
+ (CommonProxy.rand.nextDouble() - 0.5D) * (double) entity.width
* 2.0D;
var221 = prevY + (entity.posY - prevY) * var19;
var10001 = Dartcraft.proxy;
double var26
= var221 + CommonProxy.rand.nextDouble() * (double) entity.height;
var221 = prevZ + (entity.posZ - prevZ) * var19;
var10001 = Dartcraft.proxy;
double var28 = var221
+ (CommonProxy.rand.nextDouble() - 0.5D) * (double) entity.width
* 2.0D;
world.spawnParticle(
"portal",
var24,
var26,
var28,
(double) var21,
(double) var22,
(double) var23
);
}
} else if (sound) {
world.playSoundEffect(
prevX, prevY, prevZ, "mob.endermen.portal", 2.0F, DartUtils.randomPitch()
);
world.playSoundAtEntity(
entity, "mob.endermen.portal", 2.0F, DartUtils.randomPitch()
);
}
}
public static void makeEnderEffects(
Entity entity,
double posX,
double posY,
double posZ,
double prevX,
double prevY,
double prevZ,
int number,
boolean sound
) {
if (!Dartcraft.proxy.isSimulating(entity.worldObj)) {
for (int i = 0; i < number; ++i) {
double var19 = (double) i / ((double) number - 1.0D);
float var21 = (CommonProxy.rand.nextFloat() - 0.5F) * 0.2F;
float var22 = (CommonProxy.rand.nextFloat() - 0.5F) * 0.2F;
float var23 = (CommonProxy.rand.nextFloat() - 0.5F) * 0.2F;
double var27 = prevX + (posX - prevX) * var19;
double var24 = var27
+ (CommonProxy.rand.nextDouble() - 0.5D) * (double) entity.width
* 2.0D;
var27 = prevY + (posY - prevY) * var19;
double var26
= var27 + CommonProxy.rand.nextDouble() * (double) entity.height;
var27 = prevZ + (posZ - prevZ) * var19;
double var28 = var27
+ (CommonProxy.rand.nextDouble() - 0.5D) * (double) entity.width
* 2.0D;
entity.worldObj.spawnParticle(
"portal",
var24,
var26,
var28,
(double) var21,
(double) var22,
(double) var23
);
}
} else if (sound) {
entity.worldObj.playSoundEffect(
prevX, prevY, prevZ, "mob.endermen.portal", 2.0F, 1.0F
);
entity.worldObj.playSoundAtEntity(entity, "mob.endermen.portal", 2.0F, 1.0F);
}
}
@SideOnly(Side.CLIENT)
public static void makeChangeEffects(
World world, double x2, double y2, double z2, int type, int particles
) {
float modifier = 0.5F;
float velModifier = 1.0F;
EffectRenderer renderer = Dartcraft.proxy.getClientInstance().effectRenderer;
for (int i = 0; i < particles; ++i) {
CommonProxy var10001 = Dartcraft.proxy;
float x = (float) (x2 + (double) (CommonProxy.rand.nextFloat() * modifier)
- (double) (modifier / 2.0F));
var10001 = Dartcraft.proxy;
float y = (float) (y2 + (double) (CommonProxy.rand.nextFloat() * modifier)
- (double) (modifier / 2.0F));
var10001 = Dartcraft.proxy;
float z = (float) (z2 + (double) (CommonProxy.rand.nextFloat() * modifier)
- (double) (modifier / 2.0F));
// TODO
//renderer.addEffect(
// new FXWindWaker(world, (double) x, (double) y, (double) z, 16777215,
// type)
//);
}
}
@SideOnly(Side.CLIENT)
public static void
makeWingEffects(World world, double x, double y, double z, int particles) {
EffectRenderer renderer = Dartcraft.proxy.getClientInstance().effectRenderer;
float modifier = 1.0F;
for (int i = 0; i < particles; ++i) {
CommonProxy var10001 = Dartcraft.proxy;
float x2 = (float) (x + (double) (CommonProxy.rand.nextFloat() * modifier));
var10001 = Dartcraft.proxy;
float y2 = (float) (y + (double) (CommonProxy.rand.nextFloat() * modifier));
var10001 = Dartcraft.proxy;
float z2 = (float) (z + (double) (CommonProxy.rand.nextFloat() * modifier));
// TODO
//renderer.addEffect(
// new FXWindWaker(world, (double) x2, (double) y2, (double) z2, '\ue4ff',
// 0)
//);
}
}
@SideOnly(Side.CLIENT)
public static void
makeSkateEffects(World world, double x, double y, double z, int particles) {
EffectRenderer renderer = Dartcraft.proxy.getClientInstance().effectRenderer;
float modifier = 1.0F;
for (int i = 0; i < particles; ++i) {
CommonProxy var10001 = Dartcraft.proxy;
float x2 = (float) (x + (double) (CommonProxy.rand.nextFloat() * modifier));
var10001 = Dartcraft.proxy;
float y2 = (float) (y + (double) (CommonProxy.rand.nextFloat() * modifier));
var10001 = Dartcraft.proxy;
float z2 = (float) (z + (double) (CommonProxy.rand.nextFloat() * modifier));
// TODO
//renderer.addEffect(
// new FXWindWaker(world, (double) x2, (double) y2, (double) z2, '\ue4ff',
// 3)
//);
}
}
public static void spawnFlameFX(World world, int x, int y, int z) {
for (int i = 0; i < 10; ++i) {
float posX = (float) x + world.rand.nextFloat() * 1.0F;
float posY = (float) y + world.rand.nextFloat() * 1.0F;
float posZ = (float) z + world.rand.nextFloat() * 1.0F;
world.spawnParticle(
"flame", (double) posX, (double) posY, (double) posZ, 0.0D, 0.0D, 0.0D
);
}
}
public static void makeBreakFX(World world, int x, int y, int z) {
for (int i = 0; i < 10; ++i) {
float posX = (float) x + world.rand.nextFloat() * 1.0F;
float posY = (float) y + world.rand.nextFloat() * 1.0F;
float posZ = (float) z + world.rand.nextFloat() * 1.0F;
world.spawnParticle(
"portal", (double) posX, (double) posY, (double) posZ, 0.0D, 0.0D, 0.0D
);
}
}
@SideOnly(Side.CLIENT)
public static void drawTexturedQuad(
int par1, int par2, int par3, int par4, int par5, int par6, double zLevel
) {
float var7 = 0.0039063F;
float var8 = 0.0039063F;
Tessellator tessy = Tessellator.instance;
tessy.startDrawingQuads();
tessy.addVertexWithUV(
(double) (par1 + 0),
(double) (par2 + par6),
zLevel,
(double) ((float) (par3 + 0) * var7),
(double) ((float) (par4 + par6) * var8)
);
tessy.addVertexWithUV(
(double) (par1 + par5),
(double) (par2 + par6),
zLevel,
(double) ((float) (par3 + par5) * var7),
(double) ((float) (par4 + par6) * var8)
);
tessy.addVertexWithUV(
(double) (par1 + par5),
(double) (par2 + 0),
zLevel,
(double) ((float) (par3 + par5) * var7),
(double) ((float) (par4 + 0) * var8)
);
tessy.addVertexWithUV(
(double) (par1 + 0),
(double) (par2 + 0),
zLevel,
(double) ((float) (par3 + 0) * var7),
(double) ((float) (par4 + 0) * var8)
);
tessy.draw();
}
@SideOnly(Side.CLIENT)
public static void makeShiny(
World world,
double x,
double y,
double z,
int type,
int color,
int num,
boolean add
) {
EffectRenderer renderer = Dartcraft.proxy.getClientInstance().effectRenderer;
double offset = 0.0D;
if (add) {
offset += 0.5D;
}
for (int i = 0; i < num; ++i) {
// TODO: WTF
//FXDisney fx = new FXDisney(
// world,
// x + offset + world.rand.nextDouble() - world.rand.nextDouble(),
// y + world.rand.nextDouble() - world.rand.nextDouble(),
// z + offset + world.rand.nextDouble() - world.rand.nextDouble(),
// color,
// type
//);
//renderer.addEffect(fx);
}
}
@SideOnly(Side.CLIENT)
public static void makeCureEffects(
World world, double x, double y, double z, int type, int color, int num
) {
EffectRenderer renderer = Dartcraft.proxy.getClientInstance().effectRenderer;
for (int i = 0; i < num; ++i) {
// TODO
//FXCure fx = new FXCure(
// world,
// x + world.rand.nextDouble() - world.rand.nextDouble(),
// y + world.rand.nextDouble() - world.rand.nextDouble(),
// z + world.rand.nextDouble() - world.rand.nextDouble(),
// color,
// type
//);
//renderer.addEffect(fx);
}
}
@SideOnly(Side.CLIENT)
public static void makeChargeEffects(
World world,
double x,
double y,
double z,
int type,
int color,
int num,
boolean add
) {
EffectRenderer renderer = Dartcraft.proxy.getClientInstance().effectRenderer;
double offset = 0.0D;
if (add) {
offset += 0.5D;
}
for (int i = 0; i < num; ++i) {
// TODO
//FXCharge fx = new FXCharge(
// world,
// x + offset + world.rand.nextDouble() - world.rand.nextDouble(),
// y + world.rand.nextDouble() - world.rand.nextDouble(),
// z + offset + world.rand.nextDouble() - world.rand.nextDouble(),
// color,
// type
//);
//renderer.addEffect(fx);
}
}
@SideOnly(Side.CLIENT)
public static void makeIceEffects(
World world, double x, double y, double z, int type, int num, int area
) {
EffectRenderer renderer = Dartcraft.proxy.getClientInstance().effectRenderer;
int i;
if (area > 0) {
for (i = -area; i < area + 1; ++i) {
for (int fx = -area; fx < area + 1; ++fx) {
for (int k = -area; k < area + 1; ++k) {
for (int l = 0; l < num; ++l) {
// TODO
//FXIce fx1 = new FXIce(
// world,
// x + (double) i + world.rand.nextDouble()
// - world.rand.nextDouble(),
// y + (double) fx + world.rand.nextDouble()
// - world.rand.nextDouble(),
// z + (double) k + world.rand.nextDouble()
// - world.rand.nextDouble(),
// type
//);
//renderer.addEffect(fx1);
}
}
}
}
} else {
for (i = 0; i < num; ++i) {
// TODO
//FXIce var16 = new FXIce(
// world,
// x + world.rand.nextDouble() - world.rand.nextDouble(),
// y + world.rand.nextDouble() - world.rand.nextDouble(),
// z + world.rand.nextDouble() - world.rand.nextDouble(),
// type
//);
//renderer.addEffect(var16);
}
}
}
@SideOnly(Side.CLIENT)
public static void makeTimeEffects(
World world, double x, double y, double z, int type, int num, int area
) {
EffectRenderer renderer = Dartcraft.proxy.getClientInstance().effectRenderer;
int i;
if (area > 0) {
for (i = -area; i < area + 1; ++i) {
for (int fx = -area; fx < area + 1; ++fx) {
for (int k = -area; k < area + 1; ++k) {
for (int l = 0; l < num; ++l) {
// TODO
//FXTime fx1 = new FXTime(
// world,
// x + (double) i + world.rand.nextDouble()
// - world.rand.nextDouble(),
// y + (double) fx + world.rand.nextDouble()
// - world.rand.nextDouble(),
// z + (double) k + world.rand.nextDouble()
// - world.rand.nextDouble(),
// type
//);
//renderer.addEffect(fx1);
}
}
}
}
} else {
for (i = 0; i < num; ++i) {
// TODO
//FXTime var16 = new FXTime(
// world,
// x + world.rand.nextDouble() - world.rand.nextDouble(),
// y + world.rand.nextDouble() - world.rand.nextDouble(),
// z + world.rand.nextDouble() - world.rand.nextDouble(),
// type
//);
//renderer.addEffect(var16);
}
}
}
@SideOnly(Side.CLIENT)
public static void makeWWEffects(
World world, double x, double y, double z, int color, int type, int num, int area
) {
EffectRenderer renderer = Dartcraft.proxy.getClientInstance().effectRenderer;
int i;
if (area > 0) {
for (i = -area; i < area + 1; ++i) {
for (int fx = -area; fx < area + 1; ++fx) {
for (int k = -area; k < area + 1; ++k) {
for (int l = 0; l < num; ++l) {
// TODO
//FXWindWaker fx1 = new FXWindWaker(
// world,
// x + (double) i + world.rand.nextDouble()
// - world.rand.nextDouble(),
// y + (double) fx + world.rand.nextDouble()
// - world.rand.nextDouble(),
// z + (double) k + world.rand.nextDouble()
// - world.rand.nextDouble(),
// color,
// type
//);
//renderer.addEffect(fx1);
}
}
}
}
} else {
for (i = 0; i < num; ++i) {
// TODO
//FXWindWaker var17 = new FXWindWaker(
// world,
// x + world.rand.nextDouble() - world.rand.nextDouble(),
// y + world.rand.nextDouble() - world.rand.nextDouble(),
// z + world.rand.nextDouble() - world.rand.nextDouble(),
// color,
// type
//);
//renderer.addEffect(var17);
}
}
}
@SideOnly(Side.CLIENT)
public static void randomFireworkAt(World world, double x, double y, double z) {
EffectRenderer renderer = Dartcraft.proxy.getClientInstance().effectRenderer;
NBTTagCompound comp = new NBTTagCompound();
NBTTagList fireworks = new NBTTagList();
for (int fx = 0; fx < world.rand.nextInt(5) + 1; ++fx) {
NBTTagCompound tempComp = new NBTTagCompound();
tempComp.setBoolean("Flicker", world.rand.nextBoolean());
tempComp.setBoolean("Trails", world.rand.nextBoolean());
tempComp.setIntArray("Colors", randomColorArray());
tempComp.setIntArray("FadeColors", randomColorArray());
fireworks.appendTag(tempComp);
}
comp.setTag("Explosions", fireworks);
EntityFireworkStarterFX var12 = new EntityFireworkStarterFX(
world, x, y, z, 0.0D, 0.0D, 0.0D, renderer, comp
);
renderer.addEffect(var12);
}
@SideOnly(Side.CLIENT)
public static void wrathAt(World world, int x, int y, int z) {
EntityLightningBolt bolt
= new EntityLightningBolt(world, (double) x, (double) y, (double) z);
world.spawnEntityInWorld(bolt);
}
public static int[] randomColorArray() {
byte size = 16;
int[] colors = new int[size];
for (int i = 0; i < size; ++i) {
colors[i] = randomColor();
}
return colors;
}
public static int randomColor() {
int color = (int) ((float) rand.nextInt(256) * (rand.nextFloat() * 0.2F + 0.9F))
<< 16
| (int) ((float) rand.nextInt(256) * (rand.nextFloat() * 0.2F + 0.9F)) << 8
| (int) ((float) rand.nextInt(256) * (rand.nextFloat() * 0.2F + 0.9F));
return color;
}
public static int randomParticleColor() {
int color = Color.yellow.getRGB();
switch (rand.nextInt(6)) {
case 0:
color = Color.blue.getRGB();
break;
case 1:
color = Color.pink.getRGB();
break;
case 2:
color = Color.red.getRGB();
break;
case 3:
color = Color.magenta.getRGB();
break;
case 4:
color = Color.green.getRGB();
}
return color;
}
}

View File

@ -18,22 +18,24 @@ import java.util.Random;
import java.util.logging.Logger;
public class ForceConsumerUtils {
public static int getStoredForce(ItemStack stack) {
return stack != null && stack.hasTagCompound() && stack.getTagCompound().hasKey("storedForce")?stack.getTagCompound().getInteger("storedForce"):0;
return stack != null && stack.hasTagCompound()
&& stack.getTagCompound().hasKey("storedForce")
? stack.getTagCompound().getInteger("storedForce")
: 0;
}
public static void initializeForceConsumer(ItemStack stack) {
if(!stack.hasTagCompound()) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound comp = stack.getTagCompound();
NBTTagList contents = new NBTTagList();
for(int i = 0; i < 1; ++i) {
for (int i = 0; i < 1; ++i) {
NBTTagCompound itemComp = new NBTTagCompound();
itemComp.setByte("Slot", (byte)i);
itemComp.setByte("Slot", (byte) i);
contents.appendTag(itemComp);
}
@ -44,12 +46,15 @@ public class ForceConsumerUtils {
public static boolean attemptRepair(ItemStack stack) {
boolean repaired = false;
IForceConsumer consumer = null;
if(stack != null && stack.getItemDamage() > 0 && stack.getItem() instanceof IForceConsumer) {
consumer = (IForceConsumer)stack.getItem();
if (stack != null && stack.getItemDamage() > 0
&& stack.getItem() instanceof IForceConsumer) {
consumer = (IForceConsumer) stack.getItem();
}
if(consumer != null) {
for(int use = consumer.amountUsedBase(stack); stack.getItemDamage() > 0 && consumer.getStored(stack) >= use; repaired = true) {
if (consumer != null) {
for (int use = consumer.amountUsedBase(stack);
stack.getItemDamage() > 0 && consumer.getStored(stack) >= use;
repaired = true) {
stack.setItemDamage(stack.getItemDamage() - 1);
consumer.useForce(stack, use, true);
}
@ -58,86 +63,105 @@ public class ForceConsumerUtils {
return repaired;
}
public static boolean useForce(ItemStack stack, int amount, boolean use)
{
if ((stack == null) || (!stack.hasTagCompound()) || (amount < 0) || (stack.getItem() == null) || (!(stack.getItem() instanceof IForceConsumer)))
{
public static boolean useForce(ItemStack stack, int amount, boolean use) {
if ((stack == null) || (!stack.hasTagCompound()) || (amount < 0)
|| (stack.getItem() == null)
|| (!(stack.getItem() instanceof IForceConsumer))) {
return false;
}
boolean canUse = stack.getTagCompound().getInteger("storedForce") >= amount;
try
{
if (use)
{
stack.getTagCompound().setInteger("storedForce", stack.getTagCompound().getInteger("storedForce") - amount);
try {
if (use) {
stack.getTagCompound().setInteger(
"storedForce",
stack.getTagCompound().getInteger("storedForce") - amount
);
ItemInventory inv = new ItemInventory(1, stack, "consumerContents");
IForceConsumer consumer = (IForceConsumer)stack.getItem();
IForceConsumer consumer = (IForceConsumer) stack.getItem();
ItemStack invStack = inv.getStackInSlot(0);
int defecit = consumer.getMaxStored(stack) - stack.getTagCompound().getInteger("storedForce");
if ((defecit > 0) && (invStack != null) && (invStack.stackSize > 0))
{
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(new ItemStack(invStack.getItem(), 1, invStack.getItemDamage()));
int defecit = consumer.getMaxStored(stack)
- stack.getTagCompound().getInteger("storedForce");
if ((defecit > 0) && (invStack != null) && (invStack.stackSize > 0)) {
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(
new ItemStack(invStack.getItem(), 1, invStack.getItemDamage())
);
if ((liquid == null) && (invStack.getItem() == DartItems.forcegem)) {
liquid = new FluidStack(FluidRegistry.getFluid("liquidforce"), (int)(1000.0F * Config.gemValue));
liquid = new FluidStack(
FluidRegistry.getFluid("liquidforce"),
(int) (1000.0F * Config.gemValue)
);
}
if ((liquid != null) && (liquid.getFluid().getName().equalsIgnoreCase("liquidforce")))
{
while ((defecit >= liquid.amount) && (invStack.stackSize > 0))
{
stack.getTagCompound().setInteger("storedForce", stack.getTagCompound().getInteger("storedForce") + liquid.amount);
if ((liquid != null)
&& (liquid.getFluid().getName().equalsIgnoreCase("liquidforce")
)) {
while ((defecit >= liquid.amount) && (invStack.stackSize > 0)) {
stack.getTagCompound().setInteger(
"storedForce",
stack.getTagCompound().getInteger("storedForce")
+ liquid.amount
);
invStack.stackSize -= 1;
if (invStack.stackSize <= 0) {
inv.setInventorySlotContents(0, invStack.getItem().hasContainerItem() ? new ItemStack(invStack.getItem().getContainerItem()) : (ItemStack)null);
inv.setInventorySlotContents(
0,
invStack.getItem().hasContainerItem()
? new ItemStack(
invStack.getItem().getContainerItem()
)
: (ItemStack) null
);
}
inv.save();
defecit = consumer.getMaxStored(stack) - stack.getTagCompound().getInteger("storedForce");
defecit = consumer.getMaxStored(stack)
- stack.getTagCompound().getInteger("storedForce");
}
}
}
}
}
catch (Exception e)
{
Logger.getLogger("DartCraft").info("There was a problem in IForceConsumer implementation.");
} catch (Exception e) {
Logger.getLogger("DartCraft")
.info("There was a problem in IForceConsumer implementation.");
e.printStackTrace();
}
return canUse;
}
public static boolean isForceContainer(ItemStack stack)
{
public static boolean isForceContainer(ItemStack stack) {
if (stack == null) {
return false;
}
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
Fluid liquidForce = FluidRegistry.getFluid("liquidforce");
if ((liquid != null) && (liquidForce != null) && (liquid.getFluidID() == liquidForce.getID())) {
if ((liquid != null) && (liquidForce != null)
&& (liquid.getFluidID() == liquidForce.getID())) {
return true;
}
return (stack.getItem() == DartItems.forcegem) || (stack.getItem() == DartItems.forceshard);
return (stack.getItem() == DartItems.forcegem)
|| (stack.getItem() == DartItems.forceshard);
}
public static boolean openForceConsumerGui(EntityPlayer player, ItemStack stack)
{
if ((stack == null) || (stack.getItem() == null) || (!stack.hasTagCompound()) || (!(stack.getItem() instanceof IForceConsumer)) || (player == null))
{
public static boolean openForceConsumerGui(EntityPlayer player, ItemStack stack) {
if ((stack == null) || (stack.getItem() == null) || (!stack.hasTagCompound())
|| (!(stack.getItem() instanceof IForceConsumer)) || (player == null)) {
return false;
}
player.openGui(Dartcraft.instance, 16, player.worldObj, (int)player.posX, (int)player.posY, (int)player.posZ);
player.openGui(
Dartcraft.instance,
16,
player.worldObj,
(int) player.posX,
(int) player.posY,
(int) player.posZ
);
return true;
}
}

View File

@ -14,25 +14,24 @@ import java.util.HashMap;
import java.util.Iterator;
public class ForceEngineLiquids {
private static ArrayList fuels = new ArrayList();
private static ArrayList throttles = new ArrayList();
public static void load() {
assertMilk();
new ArrayList();
boolean defaults = false;
ArrayList input = Config.getFuels();
if(input == null || input.size() <= 0) {
if (input == null || input.size() <= 0) {
defaults = true;
}
try {
ArrayList e = getValues(input);
HashMap fuels = (HashMap)e.get(0);
HashMap throttles = (HashMap)e.get(1);
if(defaults || fuels.size() < 1 || throttles.size() < 1 || !fuels.containsKey("liquidforce")) {
HashMap fuels = (HashMap) e.get(0);
HashMap throttles = (HashMap) e.get(1);
if (defaults || fuels.size() < 1 || throttles.size() < 1
|| !fuels.containsKey("liquidforce")) {
throw new Exception();
}
@ -41,12 +40,17 @@ public class ForceEngineLiquids {
String name;
FluidStack e1;
EngineLiquid throttle;
while(i$.hasNext()) {
name = (String)i$.next();
while (i$.hasNext()) {
name = (String) i$.next();
try {
e1 = new FluidStack(FluidRegistry.getFluid(name), 1000);
throttle = new EngineLiquid(e1, 0, (int)((float[])fuels.get(name))[1], ((float[])fuels.get(name))[0]);
throttle = new EngineLiquid(
e1,
0,
(int) ((float[]) fuels.get(name))[1],
((float[]) fuels.get(name))[0]
);
addLiquid(throttle);
} catch (Exception err) {
err.printStackTrace();
@ -55,43 +59,56 @@ public class ForceEngineLiquids {
i$ = throttles.keySet().iterator();
while(i$.hasNext()) {
name = (String)i$.next();
while (i$.hasNext()) {
name = (String) i$.next();
try {
e1 = new FluidStack(FluidRegistry.getFluid(name), 1000);
throttle = new EngineLiquid(e1, 1, (int)((float[])throttles.get(name))[1], ((float[])throttles.get(name))[0]);
throttle = new EngineLiquid(
e1,
1,
(int) ((float[]) throttles.get(name))[1],
((float[]) throttles.get(name))[0]
);
addLiquid(throttle);
} catch (Exception err) {
err.printStackTrace();
}
}
} catch (Exception e) {
// Dartcraft..warning("There was an error loading the fuels.txt. Please configure it correctly.");
// Dartcraft..warning("There was an error loading the fuels.txt. Please
// configure it correctly.");
e.printStackTrace();
defaults = true;
}
if(defaults) {
if (defaults) {
//DartCraft.dartLog.info("Loading default Fuels.");
vanillaSupport();
buildcraftSupport();
forestrySupport();
}
}
private static void assertMilk() {
try {
if(FluidRegistry.isFluidRegistered("milk") && FluidContainerRegistry.getFluidForFilledItem(new ItemStack(Items.milk_bucket)) == null) {
if (FluidRegistry.isFluidRegistered("milk")
&& FluidContainerRegistry.getFluidForFilledItem(
new ItemStack(Items.milk_bucket)
) == null) {
Fluid e = FluidRegistry.getFluid("milk");
FluidStack milkStack = new FluidStack(e, 1000);
FluidContainerRegistry.registerFluidContainer(new FluidContainerRegistry.FluidContainerData(milkStack, new ItemStack(Items.milk_bucket), FluidContainerRegistry.EMPTY_BUCKET));
FluidContainerRegistry.registerFluidContainer(
new FluidContainerRegistry.FluidContainerData(
milkStack,
new ItemStack(Items.milk_bucket),
FluidContainerRegistry.EMPTY_BUCKET
)
);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private static ArrayList getValues(ArrayList input) {
@ -102,61 +119,77 @@ public class ForceEngineLiquids {
try {
Iterator e = input.iterator();
while(e.hasNext()) {
String check = (String)e.next();
if(check != null && check.length() > 0) {
while (e.hasNext()) {
String check = (String) e.next();
if (check != null && check.length() > 0) {
try {
String e1 = "";
float value = 0.0F;
boolean time = false;
int time1;
switch(check.charAt(0)) {
switch (check.charAt(0)) {
case 102:
e1 = check.substring(2, check.indexOf(61));
if(!fuels.containsKey(e1) && FluidRegistry.getFluid(e1) != null) {
value = (new Float(check.substring(check.indexOf(61) + 1, check.indexOf(59)))).floatValue();
time1 = (new Integer(check.substring(check.indexOf(59) + 1))).intValue();
if(value < 0.5F) {
if (!fuels.containsKey(e1)
&& FluidRegistry.getFluid(e1) != null) {
value = (new Float(check.substring(
check.indexOf(61) + 1, check.indexOf(59)
)))
.floatValue();
time1 = (new Integer(
check.substring(check.indexOf(59) + 1)
))
.intValue();
if (value < 0.5F) {
value = 0.5F;
}
if(value > 20.0F) {
if (value > 20.0F) {
value = 20.0F;
}
if(time1 < 100) {
if (time1 < 100) {
time1 = 100;
}
if(time1 > 1000000) {
if (time1 > 1000000) {
time1 = 1000000;
}
fuels.put(e1, new float[]{value, (float)time1});
fuels.put(e1, new float[] { value, (float) time1 });
}
break;
case 116:
e1 = check.substring(2, check.indexOf(61));
if(!throttles.containsKey(e1) && FluidRegistry.getFluid(e1) != null) {
value = (new Float(check.substring(check.indexOf(61) + 1, check.indexOf(59)))).floatValue();
time1 = (new Integer(check.substring(check.indexOf(59) + 1))).intValue();
if(value < 1.0F) {
if (!throttles.containsKey(e1)
&& FluidRegistry.getFluid(e1) != null) {
value = (new Float(check.substring(
check.indexOf(61) + 1, check.indexOf(59)
)))
.floatValue();
time1 = (new Integer(
check.substring(check.indexOf(59) + 1)
))
.intValue();
if (value < 1.0F) {
value = 1.0F;
}
if(value > 20.0F) {
if (value > 20.0F) {
value = 20.0F;
}
if(time1 < 100) {
if (time1 < 100) {
time1 = 100;
}
if(time1 > 1000000) {
if (time1 > 1000000) {
time1 = 1000000;
}
throttles.put(e1, new float[]{value, (float)time1});
throttles.put(
e1, new float[] { value, (float) time1 }
);
}
}
} catch (Exception e1) {
@ -176,66 +209,73 @@ public class ForceEngineLiquids {
private static void vanillaSupport() {
Fluid liquidForce = FluidRegistry.getFluid("liquidforce");
FluidStack milk = FluidRegistry.getFluidStack("milk", 1000);
if(liquidForce != null) {
addLiquid(new EngineLiquid(new FluidStack(liquidForce, 1000), 0, 20000, 4.0F));
if (liquidForce != null) {
addLiquid(new EngineLiquid(new FluidStack(liquidForce, 1000), 0, 20000, 4.0F)
);
}
if(milk != null) {
if (milk != null) {
addLiquid(new EngineLiquid(milk, 1, 3000, 2.5F));
}
addLiquid(new EngineLiquid(new FluidStack(FluidRegistry.WATER, 1000), 1, 600, 2.0F));
addLiquid(new EngineLiquid(new FluidStack(FluidRegistry.LAVA, 1000), 0, 20000, 0.5F));
addLiquid(
new EngineLiquid(new FluidStack(FluidRegistry.WATER, 1000), 1, 600, 2.0F)
);
addLiquid(
new EngineLiquid(new FluidStack(FluidRegistry.LAVA, 1000), 0, 20000, 0.5F)
);
}
private static void buildcraftSupport() {
FluidStack oil = FluidRegistry.getFluidStack("oil", 1000);
if(oil != null) {
if (oil != null) {
addLiquid(new EngineLiquid(oil, 0, 20000, 1.5F));
}
FluidStack fuel = FluidRegistry.getFluidStack("fuel", 1000);
if(fuel != null) {
if (fuel != null) {
addLiquid(new EngineLiquid(fuel, 0, 100000, 3.0F));
}
}
private static void forestrySupport() {
FluidStack crushedIce = FluidRegistry.getFluidStack("ice", 1000);
if(crushedIce != null) {
if (crushedIce != null) {
addLiquid(new EngineLiquid(crushedIce, 1, 20000, 4.0F));
}
FluidStack ethanol = FluidRegistry.getFluidStack("bioethanol", 1000);
if(ethanol != null) {
if (ethanol != null) {
addLiquid(new EngineLiquid(ethanol, 0, '\uea60', 2.0F));
}
}
public static void addLiquid(EngineLiquid liquid) {
if(liquid != null) {
if(liquid.getType() == 0 && !isThrottle(liquid.getLiquid())) {
if (liquid != null) {
if (liquid.getType() == 0 && !isThrottle(liquid.getLiquid())) {
fuels.add(liquid);
System.out.println("Added fuel: " + liquid.getLiquid().getFluid().getName());
System.out.println(
"Added fuel: " + liquid.getLiquid().getFluid().getName()
);
}
if(liquid.getType() == 1 && !isFuel(liquid.getLiquid())) {
if (liquid.getType() == 1 && !isFuel(liquid.getLiquid())) {
throttles.add(liquid);
System.out.println("Added throttle: " + liquid.getLiquid().getFluid().getName());
System.out.println(
"Added throttle: " + liquid.getLiquid().getFluid().getName()
);
}
}
}
public static boolean isFuel(FluidStack liquid) {
if(fuels != null && fuels.size() > 0 && liquid != null) {
if (fuels != null && fuels.size() > 0 && liquid != null) {
Iterator i$ = fuels.iterator();
while(i$.hasNext()) {
EngineLiquid fuel = (EngineLiquid)i$.next();
if(fuel != null && fuel.getLiquid() != null && fuel.getLiquid().isFluidEqual(liquid)) {
while (i$.hasNext()) {
EngineLiquid fuel = (EngineLiquid) i$.next();
if (fuel != null && fuel.getLiquid() != null
&& fuel.getLiquid().isFluidEqual(liquid)) {
return true;
}
}
@ -245,12 +285,13 @@ public class ForceEngineLiquids {
}
public static boolean isThrottle(FluidStack liquid) {
if(throttles != null && throttles.size() > 0 && liquid != null) {
if (throttles != null && throttles.size() > 0 && liquid != null) {
Iterator i$ = throttles.iterator();
while(i$.hasNext()) {
while (i$.hasNext()) {
EngineLiquid throttle = (EngineLiquid) i$.next();
if(throttle != null && throttle.getLiquid() != null && throttle.getLiquid().isFluidEqual(liquid)) {
if (throttle != null && throttle.getLiquid() != null
&& throttle.getLiquid().isFluidEqual(liquid)) {
return true;
}
}
@ -262,23 +303,25 @@ public class ForceEngineLiquids {
public static EngineLiquid getEngineLiquid(FluidStack liquid) {
Iterator i$;
EngineLiquid throttle;
if(fuels != null && fuels.size() > 0 && liquid != null) {
if (fuels != null && fuels.size() > 0 && liquid != null) {
i$ = fuels.iterator();
while(i$.hasNext()) {
throttle = (EngineLiquid)i$.next();
if(throttle != null && throttle.getLiquid() != null && throttle.getLiquid().isFluidEqual(liquid)) {
while (i$.hasNext()) {
throttle = (EngineLiquid) i$.next();
if (throttle != null && throttle.getLiquid() != null
&& throttle.getLiquid().isFluidEqual(liquid)) {
return throttle;
}
}
}
if(throttles != null && throttles.size() > 0 && liquid != null) {
if (throttles != null && throttles.size() > 0 && liquid != null) {
i$ = throttles.iterator();
while(i$.hasNext()) {
throttle = (EngineLiquid)i$.next();
if(throttle != null && throttle.getLiquid() != null && throttle.getLiquid().isFluidEqual(liquid)) {
while (i$.hasNext()) {
throttle = (EngineLiquid) i$.next();
if (throttle != null && throttle.getLiquid() != null
&& throttle.getLiquid().isFluidEqual(liquid)) {
return throttle;
}
}
@ -286,5 +329,4 @@ public class ForceEngineLiquids {
return null;
}
}

View File

@ -14,46 +14,78 @@ import net.minecraft.item.ItemStack;
import java.util.ArrayList;
public class ForceUpgradeManager
{
public class ForceUpgradeManager {
public static int firstUniqueID = 0;
public static final String tomeDesc = "If you haven't already done so, you should make a Book of Mudora, as it contains the sum of all DartCraft knowledge. Simply Force Transmute a Bookshelf and you'll be on your way to mastering DartCraft!";
public static final String forceDesc = "This upgrade can be used to turn certain items into more Forceful versions of themselves. It also seems to imbue Force Swords with Knockback.";
public static final String speedDesc = "This upgrade imbues Force Tools with the ability to break blocks faster, and gives an overall speed boost to players when used on a Force Rod. If used to upgrade armor the player will move faster.";
public static final String lumberjackDesc = "This upgrade transforms a Force Axe into a treebliterating tool of mass destruction, although the durability cost for such a monstrous tool is also, well, monstrous.";
public static final String damageDesc = "This upgrade serves to boost the damage of the weapon to which it is attached. On Force Swords it gives Sharpness, while Punch is given to Force Bows.";
public static final String luckDesc = "The Luck upgrade enhances the amount of loot one receives for performing almost any task. On the Force Sword it gives Looting, causing enemies slain to drop more loot. On any standard block breaking tool it will give Fortune, which increases the drop rate of certain items.";
public static final String grindingDesc = "This upgrade allows for certain items and drops to be ground into powdery substances or other useful materials. Try mining some ore with it and you'll get more return than usual.";
public static final String rainbowDesc = "This upgrade is only valid on the Force Shears and randomly changes the color of wool dropped from sheep. Try it out!";
public static final String storageDesc = "This unique upgrade serves to increase the storage capacity of Force Packs by 8 slots per upgrade, up to a total size of 40 slots. Force Packs can only be upgraded once per tier, so you'll have to get to tier 5 before you can max out any Force Pack.";
public static final String storage2Desc = "This unique upgrade serves to increase the storage capacity of Storage Units by approximately one Storage Unit per upgrade. You can only use one upgrade per tier and max size is dependent upon config settings.";
public static final String expDesc = "This upgrade has only one function: to upgrade a normal book into an Experience Tome, which is able to store an infinite amount of experience for the player. Shift right-click it to store experience, and right-click to recall it. There is a small percent loss, but it's free.";
public static final String touchDesc = "This upgrade imbues basic Force Tools with Silk Touch, which generally applies before upgrades like Grinding or Heat.";
public static final String falseDesc = "The False upgrade, when present on a Force Sword will never deal a finishing blow to an enemy when struck. This could be useful for weakening monsters so they can be easily captured in Force Flasks.";
public static final String bleedDesc = "Bleeding will cause entities that are struck to quickly take small amounts of bleed damage over time. This works on both the Force Sword and Bow and does stack with burning damage.";
public static final String craftDesc = "This upgrade is only valid for the Item Card, and will allow the card to automatically craft the configured recipe from inside a Force Pack or Force Transport Pipe.";
public static final String baneDesc = "When an entity is struck with a Bane imbued weapon they are likely to lose some of their inherent abilities. Creepers and Endermen are perfect examples of this principle.";
public static final String chargeDesc = "This upgrade can only be added to Force Armor. Each IC2 battery added gives 10k EU storage, and of course allows the Force Armor to be recharged with IC2 power.";
public static final String forgeDesc = "This upgrade is only valid for Item Cards, and allows them to transmute freely between items marked as 'equivalent' on the Ore Dictionary.";
public static final String heatDesc = "Heat is valid on every iteration of Force Tool, and has a tendency to ignite things it comes into contact with. If you put Heat on shears...you're a terrible person.";
public static final String freezingDesc = "Don't eat that cookie! It doesn't do anything anyway. Upgrading your Force Bow with Freezing will allow it to shoot Ice Arrows which will freeze your enemies in place for a short time, and even change some blocks in the world.";
public static final String wingDesc = "Wing Swords will fling their user when they right-click while holding the jump key, or allow small amounts of flight with a sneak jump right-click combination. On armor it will also allow flight and increase the maximum duration of flight.";
public static final String charge2Desc = "A more potent version of Charge, holding 100,000 EU per upgrade. Multiple Charge2 upgrades are recommended for chest pieces as they will function like Lappacks.";
public static final String healingDesc = "Healing will heal any entity it hits for 1 heart per level, unless of course that entity happens to be undead. Healing can be placed on a sword, bow and rod, and will heal the user when the rod is used.";
public static final String camoDesc = "Camo will make Force Armor invisible, if you'd rather not appear to be wearing armor, or it can be placed on a Force Rod to give short spurts of invisibility to its user.";
public static final String sightDesc = "Upgrading a Force Rod with Sight will give Night Vision to the user for about a minute per use. It's worth noting that only an unmodified Potion of Night Vision may be used.";
public static final String enderDesc = "Teleportation - not just for endermen anymore! Harness this space-bending upgrade on a Force Sword or Rod for easy transportation, or have loads of fun griefing your buddies with the Ender Bow. Teleport responsibly.";
public static final String sturdyDesc = "This upgrade can be used to imbue Unbreaking on all Force Tools but the Shears and Sword, or it can be attached to Force Armor once to reduce incoming damage by a fairly signifcant amount. Sturdy can also be used to upgrade packs and belts to make them immune to damage and despawning.";
public static final String tomeDesc
= "If you haven't already done so, you should make a Book of Mudora, as it contains the sum of all DartCraft knowledge. Simply Force Transmute a Bookshelf and you'll be on your way to mastering DartCraft!";
public static final String forceDesc
= "This upgrade can be used to turn certain items into more Forceful versions of themselves. It also seems to imbue Force Swords with Knockback.";
public static final String speedDesc
= "This upgrade imbues Force Tools with the ability to break blocks faster, and gives an overall speed boost to players when used on a Force Rod. If used to upgrade armor the player will move faster.";
public static final String lumberjackDesc
= "This upgrade transforms a Force Axe into a treebliterating tool of mass destruction, although the durability cost for such a monstrous tool is also, well, monstrous.";
public static final String damageDesc
= "This upgrade serves to boost the damage of the weapon to which it is attached. On Force Swords it gives Sharpness, while Punch is given to Force Bows.";
public static final String luckDesc
= "The Luck upgrade enhances the amount of loot one receives for performing almost any task. On the Force Sword it gives Looting, causing enemies slain to drop more loot. On any standard block breaking tool it will give Fortune, which increases the drop rate of certain items.";
public static final String grindingDesc
= "This upgrade allows for certain items and drops to be ground into powdery substances or other useful materials. Try mining some ore with it and you'll get more return than usual.";
public static final String rainbowDesc
= "This upgrade is only valid on the Force Shears and randomly changes the color of wool dropped from sheep. Try it out!";
public static final String storageDesc
= "This unique upgrade serves to increase the storage capacity of Force Packs by 8 slots per upgrade, up to a total size of 40 slots. Force Packs can only be upgraded once per tier, so you'll have to get to tier 5 before you can max out any Force Pack.";
public static final String storage2Desc
= "This unique upgrade serves to increase the storage capacity of Storage Units by approximately one Storage Unit per upgrade. You can only use one upgrade per tier and max size is dependent upon config settings.";
public static final String expDesc
= "This upgrade has only one function: to upgrade a normal book into an Experience Tome, which is able to store an infinite amount of experience for the player. Shift right-click it to store experience, and right-click to recall it. There is a small percent loss, but it's free.";
public static final String touchDesc
= "This upgrade imbues basic Force Tools with Silk Touch, which generally applies before upgrades like Grinding or Heat.";
public static final String falseDesc
= "The False upgrade, when present on a Force Sword will never deal a finishing blow to an enemy when struck. This could be useful for weakening monsters so they can be easily captured in Force Flasks.";
public static final String bleedDesc
= "Bleeding will cause entities that are struck to quickly take small amounts of bleed damage over time. This works on both the Force Sword and Bow and does stack with burning damage.";
public static final String craftDesc
= "This upgrade is only valid for the Item Card, and will allow the card to automatically craft the configured recipe from inside a Force Pack or Force Transport Pipe.";
public static final String baneDesc
= "When an entity is struck with a Bane imbued weapon they are likely to lose some of their inherent abilities. Creepers and Endermen are perfect examples of this principle.";
public static final String chargeDesc
= "This upgrade can only be added to Force Armor. Each IC2 battery added gives 10k EU storage, and of course allows the Force Armor to be recharged with IC2 power.";
public static final String forgeDesc
= "This upgrade is only valid for Item Cards, and allows them to transmute freely between items marked as 'equivalent' on the Ore Dictionary.";
public static final String heatDesc
= "Heat is valid on every iteration of Force Tool, and has a tendency to ignite things it comes into contact with. If you put Heat on shears...you're a terrible person.";
public static final String freezingDesc
= "Don't eat that cookie! It doesn't do anything anyway. Upgrading your Force Bow with Freezing will allow it to shoot Ice Arrows which will freeze your enemies in place for a short time, and even change some blocks in the world.";
public static final String wingDesc
= "Wing Swords will fling their user when they right-click while holding the jump key, or allow small amounts of flight with a sneak jump right-click combination. On armor it will also allow flight and increase the maximum duration of flight.";
public static final String charge2Desc
= "A more potent version of Charge, holding 100,000 EU per upgrade. Multiple Charge2 upgrades are recommended for chest pieces as they will function like Lappacks.";
public static final String healingDesc
= "Healing will heal any entity it hits for 1 heart per level, unless of course that entity happens to be undead. Healing can be placed on a sword, bow and rod, and will heal the user when the rod is used.";
public static final String camoDesc
= "Camo will make Force Armor invisible, if you'd rather not appear to be wearing armor, or it can be placed on a Force Rod to give short spurts of invisibility to its user.";
public static final String sightDesc
= "Upgrading a Force Rod with Sight will give Night Vision to the user for about a minute per use. It's worth noting that only an unmodified Potion of Night Vision may be used.";
public static final String enderDesc
= "Teleportation - not just for endermen anymore! Harness this space-bending upgrade on a Force Sword or Rod for easy transportation, or have loads of fun griefing your buddies with the Ender Bow. Teleport responsibly.";
public static final String sturdyDesc
= "This upgrade can be used to imbue Unbreaking on all Force Tools but the Shears and Sword, or it can be attached to Force Armor once to reduce incoming damage by a fairly signifcant amount. Sturdy can also be used to upgrade packs and belts to make them immune to damage and despawning.";
public static final String explosionDesc = "This upgrade is not yet used.";
public static final String graftingDesc = "This upgrade will give the Force Axe the potential to function as a Forestry Grafter on leaves that a grafter would normally function on. Of course this uses significant durability each time, so be prepared to throw some serious Liquid Force at this tool and apply some Sturdy upgrades if possible.";
public static final String repairDesc = "This upgrade gives the Repair enchant from Thaumcraft on Force Tools. Repair will attempt to repair one durability damage per 10 seconds.";
public static final String soulDesc = "The Soul upgrade on Force Swords and socketed Power Saws will occasionally cause Mob Chunks to drop, which can be used to craft vanilla spawners for that mob or even be smelted into colored Mob Ingots.";
public static final String lightDesc = "At the moment this can only be used to add Smite to Force Swords. (This will change eventually.)";
public static final String treasureDesc = "When entities are killed with a Treasure imbued weapon they will occasionally drop Treasure Cards, which can then be crafted into a Spoils Bag for some phat loot. Fortune increases the drop rate as well.";
public static final String imperviousDesc = "An insanely powerful upgrade that prevents any Force Tool possessing this enhancement from ever breaking.";
public static final String timeDesc = "Time is relative. At least it will be when you place this upgrade on a Force Sword or Force Rod. Shift right clicking the rod will change modes while right clicking will use it. Try it out!";
public static final String graftingDesc
= "This upgrade will give the Force Axe the potential to function as a Forestry Grafter on leaves that a grafter would normally function on. Of course this uses significant durability each time, so be prepared to throw some serious Liquid Force at this tool and apply some Sturdy upgrades if possible.";
public static final String repairDesc
= "This upgrade gives the Repair enchant from Thaumcraft on Force Tools. Repair will attempt to repair one durability damage per 10 seconds.";
public static final String soulDesc
= "The Soul upgrade on Force Swords and socketed Power Saws will occasionally cause Mob Chunks to drop, which can be used to craft vanilla spawners for that mob or even be smelted into colored Mob Ingots.";
public static final String lightDesc
= "At the moment this can only be used to add Smite to Force Swords. (This will change eventually.)";
public static final String treasureDesc
= "When entities are killed with a Treasure imbued weapon they will occasionally drop Treasure Cards, which can then be crafted into a Spoils Bag for some phat loot. Fortune increases the drop rate as well.";
public static final String imperviousDesc
= "An insanely powerful upgrade that prevents any Force Tool possessing this enhancement from ever breaking.";
public static final String timeDesc
= "Time is relative. At least it will be when you place this upgrade on a Force Sword or Force Rod. Shift right clicking the rod will change modes while right clicking will use it. Try it out!";
public static IForceUpgrade INFO;
public static IForceUpgrade FORCE;
@ -94,55 +126,217 @@ public class ForceUpgradeManager
public static ArrayList<IForceUpgrade> upgrades = new ArrayList();
public static ArrayList<IForceUpgradeMaterial> materials = new ArrayList();
public static void load()
{
public static void load() {
loadUpgrades();
addUpgrades();
loadUpgradeMaterials();
//loadWildCards();
}
private static void loadUpgrades()
{
private static void loadUpgrades() {
INFO = new IForceUpgrade(0, "Info", 1, "");
FORCE = new IForceUpgrade(1, "Force", 2, "This upgrade can be used to turn certain items into more Forceful versions of themselves. It also seems to imbue Force Swords with Knockback.");
SPEED = new IForceUpgrade(1, "Speed", Config.speedLevel, "This upgrade imbues Force Tools with the ability to break blocks faster, and gives an overall speed boost to players when used on a Force Rod. If used to upgrade armor the player will move faster.");
LUMBERJACK = new IForceUpgrade(1, "Lumberjack", 1, "This upgrade transforms a Force Axe into a treebliterating tool of mass destruction, although the durability cost for such a monstrous tool is also, well, monstrous.");
DAMAGE = new IForceUpgrade(1, "Damage", Config.damageLevel, "This upgrade serves to boost the damage of the weapon to which it is attached. On Force Swords it gives Sharpness, while Punch is given to Force Bows.");
LUCK = new IForceUpgrade(2, "Luck", 4, "The Luck upgrade enhances the amount of loot one receives for performing almost any task. On the Force Sword it gives Looting, causing enemies slain to drop more loot. On any standard block breaking tool it will give Fortune, which increases the drop rate of certain items.");
GRINDING = new IForceUpgrade(2, "Grinding", 1, "This upgrade allows for certain items and drops to be ground into powdery substances or other useful materials. Try mining some ore with it and you'll get more return than usual.");
RAINBOW = new IForceUpgrade(2, "Rainbow", 1, "This upgrade is only valid on the Force Shears and randomly changes the color of wool dropped from sheep. Try it out!");
STORAGE = new IForceUpgrade(2, "Holding", 1, "This unique upgrade serves to increase the storage capacity of Force Packs by 8 slots per upgrade, up to a total size of 40 slots. Force Packs can only be upgraded once per tier, so you'll have to get to tier 5 before you can max out any Force Pack.");
EXP = new IForceUpgrade(2, "Experience", 1, "This upgrade has only one function: to upgrade a normal book into an Experience Tome, which is able to store an infinite amount of experience for the player. Shift right-click it to store experience, and right-click to recall it. There is a small percent loss, but it's free.");
TOUCH = new IForceUpgrade(3, "Touch", 1, "This upgrade imbues basic Force Tools with Silk Touch, which generally applies before upgrades like Grinding or Heat.");
FALSE = new IForceUpgrade(3, "False", 1, "The False upgrade, when present on a Force Sword will never deal a finishing blow to an enemy when struck. This could be useful for weakening monsters so they can be easily captured in Force Flasks.");
BLEED = new IForceUpgrade(3, "Bleed", 3, "Bleeding will cause entities that are struck to quickly take small amounts of bleed damage over time. This works on both the Force Sword and Bow and does stack with burning damage.");
CRAFT = new IForceUpgrade(3, "Craft", 1, "This upgrade is only valid for the Item Card, and will allow the card to automatically craft the configured recipe from inside a Force Pack or Force Transport Pipe.");
BANE = new IForceUpgrade(3, "Bane", 1, "When an entity is struck with a Bane imbued weapon they are likely to lose some of their inherent abilities. Creepers and Endermen are perfect examples of this principle.");
TIME = new IForceUpgrade(3, "Time", 1, "Time is relative. At least it will be when you place this upgrade on a Force Sword or Force Rod. Shift right clicking the rod will change modes while right clicking will use it. Try it out!");
CHARGE = new IForceUpgrade(4, "Charge", 5, "This upgrade can only be added to Force Armor. Each IC2 battery added gives 10k EU storage, and of course allows the Force Armor to be recharged with IC2 power.");
FORGE = new IForceUpgrade(4, "Forge", 1, "This upgrade is only valid for Item Cards, and allows them to transmute freely between items marked as 'equivalent' on the Ore Dictionary.");
HEAT = new IForceUpgrade(4, "Heat", 1, "Heat is valid on every iteration of Force Tool, and has a tendency to ignite things it comes into contact with. If you put Heat on shears...you're a terrible person.");
FREEZING = new IForceUpgrade(4, "Freezing", 1, "Don't eat that cookie! It doesn't do anything anyway. Upgrading your Force Bow with Freezing will allow it to shoot Ice Arrows which will freeze your enemies in place for a short time, and even change some blocks in the world.");
STORAGE2 = new IForceUpgrade(4, "Storage", 1, "This unique upgrade serves to increase the storage capacity of Storage Units by approximately one Storage Unit per upgrade. You can only use one upgrade per tier and max size is dependent upon config settings.");
WING = new IForceUpgrade(5, "Wing", 1, "Wing Swords will fling their user when they right-click while holding the jump key, or allow small amounts of flight with a sneak jump right-click combination. On armor it will also allow flight and increase the maximum duration of flight.");
CHARGE2 = new IForceUpgrade(5, "Charge2", 5, "A more potent version of Charge, holding 100,000 EU per upgrade. Multiple Charge2 upgrades are recommended for chest pieces as they will function like Lappacks.");
HEALING = new IForceUpgrade(5, "Healing", 2, "Healing will heal any entity it hits for 1 heart per level, unless of course that entity happens to be undead. Healing can be placed on a sword, bow and rod, and will heal the user when the rod is used.");
CAMO = new IForceUpgrade(5, "Camo", 1, "Camo will make Force Armor invisible, if you'd rather not appear to be wearing armor, or it can be placed on a Force Rod to give short spurts of invisibility to its user.");
SIGHT = new IForceUpgrade(5, "Sight", 1, "Upgrading a Force Rod with Sight will give Night Vision to the user for about a minute per use. It's worth noting that only an unmodified Potion of Night Vision may be used.");
ENDER = new IForceUpgrade(6, "Ender", 1, "Teleportation - not just for endermen anymore! Harness this space-bending upgrade on a Force Sword or Rod for easy transportation, or have loads of fun griefing your buddies with the Ender Bow. Teleport responsibly.");
STURDY = new IForceUpgrade(6, "Sturdy", Config.sturdyLevel, "This upgrade can be used to imbue Unbreaking on all Force Tools but the Shears and Sword, or it can be attached to Force Armor once to reduce incoming damage by a fairly signifcant amount. Sturdy can also be used to upgrade packs and belts to make them immune to damage and despawning.");
SOUL = new IForceUpgrade(6, "Soul", 1, "The Soul upgrade on Force Swords and socketed Power Saws will occasionally cause Mob Chunks to drop, which can be used to craft vanilla spawners for that mob or even be smelted into colored Mob Ingots.");
FORCE = new IForceUpgrade(
1,
"Force",
2,
"This upgrade can be used to turn certain items into more Forceful versions of themselves. It also seems to imbue Force Swords with Knockback."
);
SPEED = new IForceUpgrade(
1,
"Speed",
Config.speedLevel,
"This upgrade imbues Force Tools with the ability to break blocks faster, and gives an overall speed boost to players when used on a Force Rod. If used to upgrade armor the player will move faster."
);
LUMBERJACK = new IForceUpgrade(
1,
"Lumberjack",
1,
"This upgrade transforms a Force Axe into a treebliterating tool of mass destruction, although the durability cost for such a monstrous tool is also, well, monstrous."
);
DAMAGE = new IForceUpgrade(
1,
"Damage",
Config.damageLevel,
"This upgrade serves to boost the damage of the weapon to which it is attached. On Force Swords it gives Sharpness, while Punch is given to Force Bows."
);
LUCK = new IForceUpgrade(
2,
"Luck",
4,
"The Luck upgrade enhances the amount of loot one receives for performing almost any task. On the Force Sword it gives Looting, causing enemies slain to drop more loot. On any standard block breaking tool it will give Fortune, which increases the drop rate of certain items."
);
GRINDING = new IForceUpgrade(
2,
"Grinding",
1,
"This upgrade allows for certain items and drops to be ground into powdery substances or other useful materials. Try mining some ore with it and you'll get more return than usual."
);
RAINBOW = new IForceUpgrade(
2,
"Rainbow",
1,
"This upgrade is only valid on the Force Shears and randomly changes the color of wool dropped from sheep. Try it out!"
);
STORAGE = new IForceUpgrade(
2,
"Holding",
1,
"This unique upgrade serves to increase the storage capacity of Force Packs by 8 slots per upgrade, up to a total size of 40 slots. Force Packs can only be upgraded once per tier, so you'll have to get to tier 5 before you can max out any Force Pack."
);
EXP = new IForceUpgrade(
2,
"Experience",
1,
"This upgrade has only one function: to upgrade a normal book into an Experience Tome, which is able to store an infinite amount of experience for the player. Shift right-click it to store experience, and right-click to recall it. There is a small percent loss, but it's free."
);
TOUCH = new IForceUpgrade(
3,
"Touch",
1,
"This upgrade imbues basic Force Tools with Silk Touch, which generally applies before upgrades like Grinding or Heat."
);
FALSE = new IForceUpgrade(
3,
"False",
1,
"The False upgrade, when present on a Force Sword will never deal a finishing blow to an enemy when struck. This could be useful for weakening monsters so they can be easily captured in Force Flasks."
);
BLEED = new IForceUpgrade(
3,
"Bleed",
3,
"Bleeding will cause entities that are struck to quickly take small amounts of bleed damage over time. This works on both the Force Sword and Bow and does stack with burning damage."
);
CRAFT = new IForceUpgrade(
3,
"Craft",
1,
"This upgrade is only valid for the Item Card, and will allow the card to automatically craft the configured recipe from inside a Force Pack or Force Transport Pipe."
);
BANE = new IForceUpgrade(
3,
"Bane",
1,
"When an entity is struck with a Bane imbued weapon they are likely to lose some of their inherent abilities. Creepers and Endermen are perfect examples of this principle."
);
TIME = new IForceUpgrade(
3,
"Time",
1,
"Time is relative. At least it will be when you place this upgrade on a Force Sword or Force Rod. Shift right clicking the rod will change modes while right clicking will use it. Try it out!"
);
CHARGE = new IForceUpgrade(
4,
"Charge",
5,
"This upgrade can only be added to Force Armor. Each IC2 battery added gives 10k EU storage, and of course allows the Force Armor to be recharged with IC2 power."
);
FORGE = new IForceUpgrade(
4,
"Forge",
1,
"This upgrade is only valid for Item Cards, and allows them to transmute freely between items marked as 'equivalent' on the Ore Dictionary."
);
HEAT = new IForceUpgrade(
4,
"Heat",
1,
"Heat is valid on every iteration of Force Tool, and has a tendency to ignite things it comes into contact with. If you put Heat on shears...you're a terrible person."
);
FREEZING = new IForceUpgrade(
4,
"Freezing",
1,
"Don't eat that cookie! It doesn't do anything anyway. Upgrading your Force Bow with Freezing will allow it to shoot Ice Arrows which will freeze your enemies in place for a short time, and even change some blocks in the world."
);
STORAGE2 = new IForceUpgrade(
4,
"Storage",
1,
"This unique upgrade serves to increase the storage capacity of Storage Units by approximately one Storage Unit per upgrade. You can only use one upgrade per tier and max size is dependent upon config settings."
);
WING = new IForceUpgrade(
5,
"Wing",
1,
"Wing Swords will fling their user when they right-click while holding the jump key, or allow small amounts of flight with a sneak jump right-click combination. On armor it will also allow flight and increase the maximum duration of flight."
);
CHARGE2 = new IForceUpgrade(
5,
"Charge2",
5,
"A more potent version of Charge, holding 100,000 EU per upgrade. Multiple Charge2 upgrades are recommended for chest pieces as they will function like Lappacks."
);
HEALING = new IForceUpgrade(
5,
"Healing",
2,
"Healing will heal any entity it hits for 1 heart per level, unless of course that entity happens to be undead. Healing can be placed on a sword, bow and rod, and will heal the user when the rod is used."
);
CAMO = new IForceUpgrade(
5,
"Camo",
1,
"Camo will make Force Armor invisible, if you'd rather not appear to be wearing armor, or it can be placed on a Force Rod to give short spurts of invisibility to its user."
);
SIGHT = new IForceUpgrade(
5,
"Sight",
1,
"Upgrading a Force Rod with Sight will give Night Vision to the user for about a minute per use. It's worth noting that only an unmodified Potion of Night Vision may be used."
);
ENDER = new IForceUpgrade(
6,
"Ender",
1,
"Teleportation - not just for endermen anymore! Harness this space-bending upgrade on a Force Sword or Rod for easy transportation, or have loads of fun griefing your buddies with the Ender Bow. Teleport responsibly."
);
STURDY = new IForceUpgrade(
6,
"Sturdy",
Config.sturdyLevel,
"This upgrade can be used to imbue Unbreaking on all Force Tools but the Shears and Sword, or it can be attached to Force Armor once to reduce incoming damage by a fairly signifcant amount. Sturdy can also be used to upgrade packs and belts to make them immune to damage and despawning."
);
SOUL = new IForceUpgrade(
6,
"Soul",
1,
"The Soul upgrade on Force Swords and socketed Power Saws will occasionally cause Mob Chunks to drop, which can be used to craft vanilla spawners for that mob or even be smelted into colored Mob Ingots."
);
EXPLOSION = new IForceUpgrade(7, "Explosion", 1, "This upgrade is not yet used.");
GRAFTING = new IForceUpgrade(7, "Grafting", 1, "This upgrade will give the Force Axe the potential to function as a Forestry Grafter on leaves that a grafter would normally function on. Of course this uses significant durability each time, so be prepared to throw some serious Liquid Force at this tool and apply some Sturdy upgrades if possible.");
REPAIR = new IForceUpgrade(7, "Repair", 1, "This upgrade gives the Repair enchant from Thaumcraft on Force Tools. Repair will attempt to repair one durability damage per 10 seconds.");
LIGHT = new IForceUpgrade(7, "Light", 5, "At the moment this can only be used to add Smite to Force Swords. (This will change eventually.)");
TREASURE = new IForceUpgrade(7, "Treasure", 1, "When entities are killed with a Treasure imbued weapon they will occasionally drop Treasure Cards, which can then be crafted into a Spoils Bag for some phat loot. Fortune increases the drop rate as well.");
IMPERVIOUS = new IForceUpgrade(7, "Impervious", 1, "An insanely powerful upgrade that prevents any Force Tool possessing this enhancement from ever breaking.");
GRAFTING = new IForceUpgrade(
7,
"Grafting",
1,
"This upgrade will give the Force Axe the potential to function as a Forestry Grafter on leaves that a grafter would normally function on. Of course this uses significant durability each time, so be prepared to throw some serious Liquid Force at this tool and apply some Sturdy upgrades if possible."
);
REPAIR = new IForceUpgrade(
7,
"Repair",
1,
"This upgrade gives the Repair enchant from Thaumcraft on Force Tools. Repair will attempt to repair one durability damage per 10 seconds."
);
LIGHT = new IForceUpgrade(
7,
"Light",
5,
"At the moment this can only be used to add Smite to Force Swords. (This will change eventually.)"
);
TREASURE = new IForceUpgrade(
7,
"Treasure",
1,
"When entities are killed with a Treasure imbued weapon they will occasionally drop Treasure Cards, which can then be crafted into a Spoils Bag for some phat loot. Fortune increases the drop rate as well."
);
IMPERVIOUS = new IForceUpgrade(
7,
"Impervious",
1,
"An insanely powerful upgrade that prevents any Force Tool possessing this enhancement from ever breaking."
);
}
private static void addUpgrades()
{
private static void addUpgrades() {
addUpgrade(INFO);
addUpgrade(FORCE);
addUpgrade(DAMAGE);
@ -182,71 +376,304 @@ public class ForceUpgradeManager
addUpgrade(IMPERVIOUS);
}
private static void loadUpgradeMaterials()
{
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.resource, 416, INFO.getID(), 0, 0.0F, "If you haven't already done so, you should make a Book of Mudora, as it contains the sum of all DartCraft knowledge. Simply Force Transmute a Bookshelf and you'll be on your way to mastering DartCraft!", false));
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.forcenugget, FORCE.getID(), -5, 0.75F, "It appears to be a small fragment of Force. Perhaps I could use this to modify a sword.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.claw, DAMAGE.getID(), 0, 0.75F, "They say that bats hold the secret to increased damage.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(Items.sugar, SPEED.getID(), 0, 1.0F, "Tastes like win, and diabetes.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.resource, 128, FALSE.getID(), 10, 1.5F, "It appears to be some sort of dust left behind by a Flask-wielding lunatic.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(Item.getItemFromBlock(DartBlocks.forcelog), LUMBERJACK.getID(), 5, 1.5F, "Apparently these Forceful Logs hold the power to quickly destroying their brethren.", true));
private static void loadUpgradeMaterials() {
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.resource,
416,
INFO.getID(),
0,
0.0F,
"If you haven't already done so, you should make a Book of Mudora, as it contains the sum of all DartCraft knowledge. Simply Force Transmute a Bookshelf and you'll be on your way to mastering DartCraft!",
false
));
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.forcenugget,
FORCE.getID(),
-5,
0.75F,
"It appears to be a small fragment of Force. Perhaps I could use this to modify a sword.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.claw,
DAMAGE.getID(),
0,
0.75F,
"They say that bats hold the secret to increased damage.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.sugar, SPEED.getID(), 0, 1.0F, "Tastes like win, and diabetes.", true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.resource,
128,
FALSE.getID(),
10,
1.5F,
"It appears to be some sort of dust left behind by a Flask-wielding lunatic.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Item.getItemFromBlock(DartBlocks.forcelog),
LUMBERJACK.getID(),
5,
1.5F,
"Apparently these Forceful Logs hold the power to quickly destroying their brethren.",
true
));
if (!Config.hardHeat) {
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.goldenpower, HEAT.getID(), 5, 1.5F, "This Golden Power is not so hard to obtain.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.goldenpower,
HEAT.getID(),
5,
1.5F,
"This Golden Power is not so hard to obtain.",
true
));
} else {
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.potionitem,
8195,
HEAT.getID(),
10,
2.0F,
"This fiery brew seems like it would help one to swim in lava... Successfully that is.",
true
));
}
else {
addMaterial(UpgradeMaterialHelper.createMaterial(Items.potionitem, 8195, HEAT.getID(), 10, 2.0F, "This fiery brew seems like it would help one to swim in lava... Successfully that is.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.dye,
4,
RAINBOW.getID(),
0,
0.25F,
"Colorful cloth abounds with this gorgeous gem.",
true
));
if (!Config.hardSturdy) {
addMaterial(UpgradeMaterialHelper.createMaterial(
Item.getItemFromBlock(Blocks.brick_block),
STURDY.getID(),
0,
1.25F,
"Well, at least it's harder than dirt.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Item.getItemFromBlock(Blocks.obsidian),
STURDY.getID(),
10,
1.75F,
"Collecting this surrepticiously sturdy stone can be a seriously strenuous stint.",
true
));
}
addMaterial(UpgradeMaterialHelper.createMaterial(Items.dye, 4, RAINBOW.getID(), 0, 0.25F, "Colorful cloth abounds with this gorgeous gem.", true));
if (!Config.hardSturdy)
{
addMaterial(UpgradeMaterialHelper.createMaterial(Item.getItemFromBlock(Blocks.brick_block), STURDY.getID(), 0, 1.25F, "Well, at least it's harder than dirt.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(Item.getItemFromBlock(Blocks.obsidian), STURDY.getID(), 10, 1.75F, "Collecting this surrepticiously sturdy stone can be a seriously strenuous stint.", true));
}
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.resource, 129, STURDY.getID(), 25, 3.0F, "The hardest substance known to post-apocalyptic blocky man, ground into a powdery substance.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.fortune, LUCK.getID(), 0, 2.0F, "A nugget of otherworldly wisdom stuffed inside a delicious confection", true));
addMaterial(UpgradeMaterialHelper.createMaterial(Item.getItemFromBlock(Blocks.web), TOUCH.getID(), 5, 2.0F, "Spiders aren't the only ones who can weave this Silky material.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(Items.arrow, BLEED.getID(), 0, 1.0F, "You'll shoot your eye out!", true));
addMaterial(UpgradeMaterialHelper.createMaterial(Items.spider_eye, BANE.getID(), 10, 1.5F, "You probably shouldn't eat this... Just jam it on a sword.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.resource, 134, STORAGE.getID(), 0, 0.25F, "I might try and upgrade a Force Pack with this strange item.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.resource, 135, STORAGE2.getID(), 0, 0.5F, "It looks like this item could increase the storage capacity of a Storage Unit.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.resource,
129,
STURDY.getID(),
25,
3.0F,
"The hardest substance known to post-apocalyptic blocky man, ground into a powdery substance.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.fortune,
LUCK.getID(),
0,
2.0F,
"A nugget of otherworldly wisdom stuffed inside a delicious confection",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Item.getItemFromBlock(Blocks.web),
TOUCH.getID(),
5,
2.0F,
"Spiders aren't the only ones who can weave this Silky material.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.arrow, BLEED.getID(), 0, 1.0F, "You'll shoot your eye out!", true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.spider_eye,
BANE.getID(),
10,
1.5F,
"You probably shouldn't eat this... Just jam it on a sword.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.resource,
134,
STORAGE.getID(),
0,
0.25F,
"I might try and upgrade a Force Pack with this strange item.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.resource,
135,
STORAGE2.getID(),
0,
0.5F,
"It looks like this item could increase the storage capacity of a Storage Unit.",
true
));
if (Config.easyWing) {
addMaterial(UpgradeMaterialHelper.createMaterial(Items.feather, WING.getID(), 0, 3.0F, "The traditional symbol of freedom... and avian flu.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.feather,
WING.getID(),
0,
3.0F,
"The traditional symbol of freedom... and avian flu.",
true
));
}
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.resource, 131, WING.getID(), 5, 3.0F, "The traditional symbol of freedom... and avian flu.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(Items.flint, GRINDING.getID(), 0, 1.5F, "This is either a rock, or a really misshapen pancreas.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(Items.ghast_tear, HEALING.getID(), 10, 2.0F, "Your tears give me strength... and regeneration.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(Items.potionitem, 8206, CAMO.getID(), 5, 2.0F, "Nothing to see here, except a floating set of armor.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(Items.potionitem, 8198, SIGHT.getID(), 5, 2.0F, "I'm pretty sure it's a potion of some kind, but then again I'm just a sentence. Perhaps if I could just See a little better...", true));
addMaterial(UpgradeMaterialHelper.createMaterial(Item.getItemFromBlock(Blocks.crafting_table), CRAFT.getID(), -20, 1.0F, "A very Crafty block.", false));
addMaterial(UpgradeMaterialHelper.createMaterial(Item.getItemFromBlock(Blocks.furnace), FORGE.getID(), -25, 2.0F, "Our best traits are Forged by fire. Perhaps an Item Card might be able to use this.", false));
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.resource,
131,
WING.getID(),
5,
3.0F,
"The traditional symbol of freedom... and avian flu.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.flint,
GRINDING.getID(),
0,
1.5F,
"This is either a rock, or a really misshapen pancreas.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.ghast_tear,
HEALING.getID(),
10,
2.0F,
"Your tears give me strength... and regeneration.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.potionitem,
8206,
CAMO.getID(),
5,
2.0F,
"Nothing to see here, except a floating set of armor.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.potionitem,
8198,
SIGHT.getID(),
5,
2.0F,
"I'm pretty sure it's a potion of some kind, but then again I'm just a sentence. Perhaps if I could just See a little better...",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Item.getItemFromBlock(Blocks.crafting_table),
CRAFT.getID(),
-20,
1.0F,
"A very Crafty block.",
false
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Item.getItemFromBlock(Blocks.furnace),
FORGE.getID(),
-25,
2.0F,
"Our best traits are Forged by fire. Perhaps an Item Card might be able to use this.",
false
));
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.resource, 195, FREEZING.getID(), 0, 2.0F, "Is this made out of snow?", true));
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.resource,
195,
FREEZING.getID(),
0,
2.0F,
"Is this made out of snow?",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(Items.ender_pearl, ENDER.getID(), 0, 5.0F, "This dark orb must house some potent spatial magic.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(Items.experience_bottle, EXP.getID(), 15, 2.25F, "I might be able to get one from an Enchanted Book. Now where did that Force Rod go? If I can manage to get one I should put it on a book.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(Items.glowstone_dust, LIGHT.getID(), 0, 3.0F, "It's glowing, yet stone-like.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.ender_pearl,
ENDER.getID(),
0,
5.0F,
"This dark orb must house some potent spatial magic.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.experience_bottle,
EXP.getID(),
15,
2.25F,
"I might be able to get one from an Enchanted Book. Now where did that Force Rod go? If I can manage to get one I should put it on a book.",
true
));
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.glowstone_dust,
LIGHT.getID(),
0,
3.0F,
"It's glowing, yet stone-like.",
true
));
if ((Config.timeUpgradeRod) || (Config.timeUpgradeSword) || (Config.timeUpgradeTorch)) {
addMaterial(UpgradeMaterialHelper.createMaterial(Items.clock, TIME.getID(), 0, 2.5F, "A perfect timepiece.", true));
if ((Config.timeUpgradeRod) || (Config.timeUpgradeSword)
|| (Config.timeUpgradeTorch)) {
addMaterial(UpgradeMaterialHelper.createMaterial(
Items.clock, TIME.getID(), 0, 2.5F, "A perfect timepiece.", true
));
}
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.resource, 132, TREASURE.getID(), 0, 8.0F, "When entities are killed with a Treasure imbued weapon they will occasionally drop Treasure Cards, which can then be crafted into a Spoils Bag for some phat loot. Fortune increases the drop rate as well.", false));
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.resource,
132,
TREASURE.getID(),
0,
8.0F,
"When entities are killed with a Treasure imbued weapon they will occasionally drop Treasure Cards, which can then be crafted into a Spoils Bag for some phat loot. Fortune increases the drop rate as well.",
false
));
if (Config.insaneImpervious) {
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.resource, 133, IMPERVIOUS.getID(), 0, 8.0F, "An insanely powerful upgrade that prevents any Force Tool possessing this enhancement from ever breaking.", false));
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.resource,
133,
IMPERVIOUS.getID(),
0,
8.0F,
"An insanely powerful upgrade that prevents any Force Tool possessing this enhancement from ever breaking.",
false
));
}
addMaterial(UpgradeMaterialHelper.createMaterial(DartItems.soulwafer, SOUL.getID(), 0, 2.0F, "The Soul upgrade on Force Swords and socketed Power Saws will occasionally cause Mob Chunks to drop, which can be used to craft vanilla spawners for that mob or even be smelted into colored Mob Ingots.", true));
addMaterial(UpgradeMaterialHelper.createMaterial(
DartItems.soulwafer,
SOUL.getID(),
0,
2.0F,
"The Soul upgrade on Force Swords and socketed Power Saws will occasionally cause Mob Chunks to drop, which can be used to craft vanilla spawners for that mob or even be smelted into colored Mob Ingots.",
true
));
}
/*private static void loadWildCards() {
ForceWildCards.addWildCard(new IForceWildCard(new ItemStack(Block.stoneBrick, 1, 0), new ItemStack(DartBlock.forceBrick, 1, 11), FORCE));
ItemStack tomeStack = new ItemStack((Item)DartItem.forceTome);
ForceWildCards.addWildCard(new IForceWildCard(new ItemStack(Block.stoneBrick, 1,
0), new ItemStack(DartBlock.forceBrick, 1, 11), FORCE)); ItemStack tomeStack = new
ItemStack((Item)DartItem.forceTome);
tomeStack.setTagCompound(TomeUtils.initExpComp());
ForceWildCards.addWildCard(new IForceWildCard(new ItemStack(Items.book), tomeStack, EXP));
ForceWildCards.addWildCard(new IForceWildCard(new ItemStack(Items.book),
tomeStack, EXP));
}*/
public static boolean addUpgrade(IForceUpgrade upgrade) {
@ -289,7 +716,9 @@ public class ForceUpgradeManager
for (IForceUpgradeMaterial mat : materials) {
if (mat == null)
continue;
if (mat.getItem() == (stack.getItem()) && (mat.getItemMeta() == stack.getItemDamage() || mat.getItemMeta() == 32767))
if (mat.getItem() == (stack.getItem())
&& (mat.getItemMeta() == stack.getItemDamage()
|| mat.getItemMeta() == 32767))
return mat;
}
return null;

View File

@ -5,7 +5,6 @@ import java.util.List;
import java.util.Random;
public class FortunesUtil {
private static Random rand;
private static List<String> fortunes = new ArrayList<String>();
@ -37,23 +36,30 @@ public class FortunesUtil {
addFortune("Whatever happened to Doritos 3D?");
addFortune("Diabetes, anyone?");
addFortune("That wasn't a cookie!");
addFortune("If a tree falls down in the woods, you have a special mod installed.");
addFortune("If a tree falls down in the woods, you have a special mod installed."
);
addFortune("The cake is a lie of omission.");
addFortune("A wise man once said, \"Yes honey, it does make you look fat.\" He never said that again.");
addFortune(
"A wise man once said, \"Yes honey, it does make you look fat.\" He never said that again."
);
addFortune("Don't stare directly at the pixels.");
addFortune("I know where you live.");
addFortune("Your lucky numbers are 0, -7, and 437922904678137496.708162");
addFortune("There is never enough redstone.");
addFortune("What you seek is surrounded by blocks.");
addFortune("Today is Tuesday, or is it Friday - I can never tell.");
addFortune("In the event of a creeper explosion, your keyboard can double as a broken keyboard.");
addFortune(
"In the event of a creeper explosion, your keyboard can double as a broken keyboard."
);
addFortune("I didn't do it.");
addFortune("You are 5.6 grams heavier than you were 10 seconds ago.");
addFortune("I dropped my cookie.");
addFortune("...Saltpeter? Really?");
addFortune("We're no strangers to love. You know the rules and so do I.");
addFortune("Eat another cookie.");
addFortune("fontRenderer.drawString(\"Totally Real Accidental Glitch\", posX, posY, 0xFFFFFF);");
addFortune(
"fontRenderer.drawString(\"Totally Real Accidental Glitch\", posX, posY, 0xFFFFFF);"
);
addFortune("I CAN believe it's not butter.");
addFortune("Beware enderman with a short fuse...");
addFortune("Remember to repair your tools.");
@ -65,25 +71,43 @@ public class FortunesUtil {
addFortune("Not all Blocks are created equal.");
addFortune("Don't touch that!");
addFortune("Always name your machinations.");
addFortune("Look in your inventory, now back to me - this fortune is now diamonds!");
addFortune(
"Look in your inventory, now back to me - this fortune is now diamonds!"
);
addFortune("Who put that there?");
addFortune("Winners never cheat and cheaters never win, unless the winners cheated, in which case the cheaters won.");
addFortune(
"Winners never cheat and cheaters never win, unless the winners cheated, in which case the cheaters won."
);
addFortune("Hi Bob! What, they can't all be zingers.");
addFortune("Have you ever thought to yourself, \"My, that's an awfully large open grave!\"");
addFortune(
"Have you ever thought to yourself, \"My, that's an awfully large open grave!\""
);
addFortune("Could you pick up my dry-cleaning?");
addFortune("Never shower in a thunderstorm. It's less efficient than bathing indoors and you'll freak out your neighbors.");
addFortune("It is said that everyone experiences hardships, but God must REALLY hate YOU.");
addFortune("If you play a country song backwards, you waste about 4 minutes of your life listening to garbled nonsense.");
addFortune(
"Never shower in a thunderstorm. It's less efficient than bathing indoors and you'll freak out your neighbors."
);
addFortune(
"It is said that everyone experiences hardships, but God must REALLY hate YOU."
);
addFortune(
"If you play a country song backwards, you waste about 4 minutes of your life listening to garbled nonsense."
);
addFortune("No, you can't make that jump.");
addFortune("I know they're furry and cuddly, but trust me, they're evil incarnate.");
addFortune(
"I know they're furry and cuddly, but trust me, they're evil incarnate."
);
addFortune("Do you Dew?");
addFortune("I see the land, but where exactly are the tracts?");
addFortune("Creepers were originally from Dr. Who.");
addFortune("Don't bogart my nasal spray!");
addFortune("You'll live.");
addFortune("Don't make me come back there!");
addFortune("I've burned everything that reminds me of you in a ritualistic bonfire.");
addFortune("We will be an unstoppable force; to our enemies we bring only death, to our allies we always bring cake.");
addFortune(
"I've burned everything that reminds me of you in a ritualistic bonfire."
);
addFortune(
"We will be an unstoppable force; to our enemies we bring only death, to our allies we always bring cake."
);
addFortune("Heavy is the head that eats the crayons.");
addFortune("Beware skinwalkers.");
addFortune("Don't fear the creeper.");
@ -154,11 +178,14 @@ public class FortunesUtil {
addFortune("Has anyone seen my Fedora?");
addFortune("I beg to defer.");
addFortune("Everybody loops.");
addFortune("Why is Count Chocula seasonal? Pedophilic vampires are always in style!");
addFortune(
"Why is Count Chocula seasonal? Pedophilic vampires are always in style!"
);
addFortune("Eekum Bokum.");
addFortune("Churba wurt!");
addFortune("Darwa jit!");
addFortune("Success is often preceded by failure, then followed again by failure.");
addFortune("Success is often preceded by failure, then followed again by failure."
);
addFortune("Man with Steve skin receive no cake.");
addFortune("It's all Melnics to me!");
addFortune("\"Steve\" means \"lazy\" in Swedish.");
@ -171,8 +198,12 @@ public class FortunesUtil {
addFortune("I'm upgrade fodder!");
addFortune("You can do anything at Zombo.com.");
addFortune("Remember to feed the cattle.");
addFortune("TROGDOR was a man. I mean, he was a dragon-man... Maybe he was just a dragon.");
addFortune("Charles in charge of our clicks left and right. Charles in charge of every block in sight.");
addFortune(
"TROGDOR was a man. I mean, he was a dragon-man... Maybe he was just a dragon."
);
addFortune(
"Charles in charge of our clicks left and right. Charles in charge of every block in sight."
);
addFortune("Charles was never really in charge.");
addFortune("Remember to use every part of the chicken.");
addFortune("I'm not responsible for this.");
@ -202,19 +233,25 @@ public class FortunesUtil {
addFortune("Bring me a shrubbery!");
addFortune("It's bigger on the inside.");
addFortune("That's what she said.");
addFortune("Have you heard the one about the Rabbi and the Priest? Oh I forgot, you're deaf.");
addFortune("There are worse appendages to get caught sticking inside the cookie jar.");
addFortune(
"Have you heard the one about the Rabbi and the Priest? Oh I forgot, you're deaf."
);
addFortune(
"There are worse appendages to get caught sticking inside the cookie jar."
);
addFortune("Ever have the feeling you're being watched? That's me!");
addFortune("He who handles his NullPointerExceptions is a wise man indeed.");
addFortune("Taking candy from a baby often prevents choking.");
addFortune("Texting while driving is a potent form of natural-selection.");
addFortune("The secret to a good marriage is matching tattoos.");
addFortune("A sucker is born every minute, however an idiot is born every two seconds.");
addFortune("Error in Thread Main: ExceptionNotCaughtException: DartCraft.java:32");
addFortune(
"A sucker is born every minute, however an idiot is born every two seconds."
);
addFortune("Error in Thread Main: ExceptionNotCaughtException: DartCraft.java:32"
);
addFortune("I'll tear YOUR stub!");
addFortune("Daydreaming is free, cookies are not.");
addFortune("PINGAS!");
addFortune("The run is dead.");
}
}

View File

@ -46,7 +46,8 @@ public class ItemCraftingInventory extends InventoryCrafting implements IInvento
int id = comp.getInteger("ID");
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
if (player.inventory.getStackInSlot(i) != null) {
NBTTagCompound playerComp = player.inventory.getStackInSlot(i).getTagCompound();
NBTTagCompound playerComp
= player.inventory.getStackInSlot(i).getTagCompound();
if (playerComp != null)
if (id == playerComp.getInteger("ID"))
return player.inventory.getStackInSlot(i);
@ -82,7 +83,7 @@ public class ItemCraftingInventory extends InventoryCrafting implements IInvento
if (comp == null)
return;
if (comp.hasKey("contents")) {
NBTTagList contentList = (NBTTagList)comp.getTag("contents");
NBTTagList contentList = (NBTTagList) comp.getTag("contents");
this.contents = new ItemStack[getSizeInventory()];
for (int i = 0; i < contentList.tagCount(); i++) {
NBTTagCompound tempComp = contentList.getCompoundTagAt(i);
@ -98,9 +99,9 @@ public class ItemCraftingInventory extends InventoryCrafting implements IInvento
for (int i = 0; i < this.contents.length; i++) {
if (this.contents[i] != null) {
NBTTagCompound tempComp = new NBTTagCompound();
tempComp.setByte("Slot", (byte)i);
tempComp.setByte("Slot", (byte) i);
this.contents[i].writeToNBT(tempComp);
contentList.appendTag((NBTBase)tempComp);
contentList.appendTag((NBTBase) tempComp);
}
comp.setTag("contents", (NBTBase) contentList);
}
@ -111,7 +112,8 @@ public class ItemCraftingInventory extends InventoryCrafting implements IInvento
}
public ItemStack decrStackSize(int i, int j) {
if (this.contents == null || this.contents.length <= i || i < 0 || this.contents[i] == null)
if (this.contents == null || this.contents.length <= i || i < 0
|| this.contents[i] == null)
return null;
if ((this.contents[i]).stackSize <= j) {
ItemStack itemStack = this.contents[i];
@ -127,7 +129,8 @@ public class ItemCraftingInventory extends InventoryCrafting implements IInvento
}
public ItemStack getStackInSlotOnClosing(int slot) {
if (this.contents == null || this.contents.length <= slot || slot < 0 || this.contents[slot] == null)
if (this.contents == null || this.contents.length <= slot || slot < 0
|| this.contents[slot] == null)
return null;
ItemStack returnVal = this.contents[slot];
this.contents[slot] = null;
@ -173,4 +176,3 @@ public class ItemCraftingInventory extends InventoryCrafting implements IInvento
return true;
}
}

View File

@ -1,5 +1,7 @@
package ley.modding.dartcraft.util;
import com.google.common.base.Objects;
import ley.modding.dartcraft.Dartcraft;
import ley.modding.dartcraft.proxy.CommonProxy;
import net.minecraft.entity.Entity;
@ -9,8 +11,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class ItemUtils {
public static void dropItem(ItemStack stack, World world, double x, double y, double z) {
public static void
dropItem(ItemStack stack, World world, double x, double y, double z) {
if (stack != null && world != null && Dartcraft.proxy.isSimulating(world)) {
float xRand = CommonProxy.rand.nextFloat() * 0.2F + 0.1F;
float yRand = CommonProxy.rand.nextFloat() * 0.8F + 0.1F;
@ -20,21 +22,34 @@ public class ItemUtils {
if (randInt > stack.stackSize)
randInt = stack.stackSize;
stack.stackSize -= randInt;
EntityItem droppedItem = new EntityItem(world, ((float)x + xRand), ((float)y + yRand), ((float)z + zRand), new ItemStack(stack.getItem(), randInt, stack.getItemDamage()));
EntityItem droppedItem = new EntityItem(
world,
((float) x + xRand),
((float) y + yRand),
((float) z + zRand),
new ItemStack(stack.getItem(), randInt, stack.getItemDamage())
);
if (stack.hasTagCompound())
droppedItem.getEntityItem().setTagCompound((NBTTagCompound) stack
.getTagCompound().copy());
droppedItem.getEntityItem().setTagCompound(
(NBTTagCompound) stack.getTagCompound().copy()
);
float modifier = 0.025F;
((Entity)droppedItem)
.motionX = ((float)CommonProxy.rand.nextGaussian() * modifier);
((Entity)droppedItem)
.motionY = ((float)CommonProxy.rand.nextGaussian() * modifier + 0.2F);
((Entity)droppedItem)
.motionZ = ((float)CommonProxy.rand.nextGaussian() * modifier);
((Entity) droppedItem).motionX
= ((float) CommonProxy.rand.nextGaussian() * modifier);
((Entity) droppedItem).motionY
= ((float) CommonProxy.rand.nextGaussian() * modifier + 0.2F);
((Entity) droppedItem).motionZ
= ((float) CommonProxy.rand.nextGaussian() * modifier);
droppedItem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld((Entity)droppedItem);
world.spawnEntityInWorld((Entity) droppedItem);
}
}
}
public static boolean areStacksSame(ItemStack stack1, ItemStack stack2) {
return stack1 != null && stack2 != null ? stack1.getItem() == stack2.getItem()
&& stack1.getItemDamage() == stack2.getItemDamage()
&& Objects.equal(stack1.getTagCompound(), stack2.getTagCompound())
: false;
}
}

View File

@ -21,7 +21,9 @@ public class GenForceTree extends WorldGenAbstractTree {
this(doBlockNotify, 4, 0, 0);
}
public GenForceTree(boolean doBlockNotify, int minTreeHeight, int metaWood, int metaLeaves) {
public GenForceTree(
boolean doBlockNotify, int minTreeHeight, int metaWood, int metaLeaves
) {
super(doBlockNotify);
this.minTreeHeight = minTreeHeight;
this.metaWood = metaWood;
@ -69,10 +71,15 @@ public class GenForceTree extends WorldGenAbstractTree {
} else {
Block block2 = world.getBlock(x, y - 1, z);
boolean isSoil =
block2.canSustainPlant(
boolean isSoil = block2.canSustainPlant(
world, x, y - 1, z, ForgeDirection.UP, (BlockSapling) DartBlocks.forcesapling);
world,
x,
y - 1,
z,
ForgeDirection.UP,
(BlockSapling) DartBlocks.forcesapling
);
if (isSoil && y < 256 - treeHeight - 1) {
block2.onPlantGrow(world, x, y - 1, z, x, y, z);
b0 = 3;
@ -92,12 +99,20 @@ public class GenForceTree extends WorldGenAbstractTree {
for (int k2 = z - l1; k2 <= z + l1; ++k2) {
int l2 = k2 - z;
if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || rand.nextInt(2) != 0 && i3 != 0) {
if (Math.abs(j2) != l1 || Math.abs(l2) != l1
|| rand.nextInt(2) != 0 && i3 != 0) {
Block block1 = world.getBlock(i2, k1, k2);
if (block1.isAir(world, i2, k1, k2) || block1.isLeaves(world, i2, k1, k2)) {
if (block1.isAir(world, i2, k1, k2)
|| block1.isLeaves(world, i2, k1, k2)) {
this.setBlockAndNotifyAdequately(
world, i2, k1, k2, DartBlocks.forceleaves, this.metaLeaves);
world,
i2,
k1,
k2,
DartBlocks.forceleaves,
this.metaLeaves
);
}
}
}
@ -107,8 +122,11 @@ public class GenForceTree extends WorldGenAbstractTree {
for (k1 = 0; k1 < treeHeight; ++k1) {
block = world.getBlock(x, y + k1, z);
if (block.isAir(world, x, y + k1, z) || block.isLeaves(world, x, y + k1, z)) {
this.setBlockAndNotifyAdequately(world, x, y + k1, z, DartBlocks.forcelog, this.metaWood);
if (block.isAir(world, x, y + k1, z)
|| block.isLeaves(world, x, y + k1, z)) {
this.setBlockAndNotifyAdequately(
world, x, y + k1, z, DartBlocks.forcelog, this.metaWood
);
}
}
@ -122,4 +140,3 @@ public class GenForceTree extends WorldGenAbstractTree {
}
}
}

View File

@ -11,13 +11,22 @@ import net.minecraft.world.gen.feature.WorldGenMinable;
import java.util.Random;
public class OreGen implements IWorldGenerator {
WorldGenMinable powerMinable
= new WorldGenMinable(DartBlocks.powerore, Config.powerOreFreq);
WorldGenMinable powerMinable = new WorldGenMinable(DartBlocks.powerore, Config.powerOreFreq);
WorldGenMinable netherMinable = new WorldGenMinable(DartBlocks.powerore, 1, Config.powerOreFreq, Blocks.netherrack);
WorldGenMinable netherMinable = new WorldGenMinable(
DartBlocks.powerore, 1, Config.powerOreFreq, Blocks.netherrack
);
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
public void generate(
Random random,
int chunkX,
int chunkZ,
World world,
IChunkProvider chunkGenerator,
IChunkProvider chunkProvider
) {
doGeneration(random, chunkX, chunkZ, world);
}
@ -33,7 +42,7 @@ public class OreGen implements IWorldGenerator {
}
public void generateNether(Random rand, int chunkX, int chunkZ, World world) {
for (int i = 0; i < (int)(Config.powerOreRarity * Config.netherFreq); i++) {
for (int i = 0; i < (int) (Config.powerOreRarity * Config.netherFreq); i++) {
int posx = chunkX * 16 + rand.nextInt(16);
int posy = rand.nextInt(128);
int posz = chunkZ * 16 + rand.nextInt(16);
@ -49,5 +58,4 @@ public class OreGen implements IWorldGenerator {
this.powerMinable.generate(world, rand, posx, posy, posz);
}
}
}

View File

@ -0,0 +1,7 @@
package ley.modding.tileralib.api;
import net.minecraft.item.ItemBlock;
public interface ICustomItemBlockProvider {
Class<? extends ItemBlock> getItemBlockClass();
}

View File

@ -1,11 +1,9 @@
package ley.modding.tileralib.api;
public interface IIngredient {
char getKey();
int getCount();
Object getIngredient();
}

View File

@ -1,12 +1,10 @@
package ley.modding.tileralib.api;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public interface IRegistry {
String getModID();
Item registerItem(Item item);
@ -20,5 +18,4 @@ public interface IRegistry {
void addShapedRecipe(ItemStack output, String[] pattern, IIngredient[] ingredients);
void addShapelessRecipe(ItemStack output, IIngredient[] input);
}

View File

@ -3,7 +3,5 @@ package ley.modding.tileralib.api;
import net.minecraft.tileentity.TileEntity;
public interface ITEProvider {
Class<? extends TileEntity> getTEClass();
}

View File

@ -20,4 +20,21 @@ tile.forceleaves.name=Force Leaves
tile.forcesapling.name=Force Sapling
tile.forcepickaxe.name=Force Pickaxe
tile.forcebrick0.name=Black Force Brick
tile.forcebrick1.name=Red Force Brick
tile.forcebrick2.name=Green Force Brick
tile.forcebrick3.name=Brown Force Brick
tile.forcebrick4.name=Blue Force Brick
tile.forcebrick5.name=Purple Force Brick
tile.forcebrick6.name=Cyan Force Brick
tile.forcebrick7.name=Light Gray Force Brick
tile.forcebrick8.name=Gray Force Brick
tile.forcebrick9.name=Pink Force Brick
tile.forcebrick10.name=Lime Force Brick
tile.forcebrick11.name=Yellow Force Brick
tile.forcebrick12.name=Light Blue Force Brick
tile.forcebrick13.name=Magenta Force Brick
tile.forcebrick14.name=Orange Force Brick
tile.forcebrick15.name=White Force Brick
itemGroup.dartcraft=Dartcraft

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB