bug fix and bug fix

This commit is contained in:
Towdium committed 2016-03-03 14:46:38 +08:00
1 parent 1555a7cffa
commit 2c1ff88d31
8 files changed
+53 -13

No files matched your search

+1 -1
View File
@@ -20,7 +20,7 @@ plugins {
id "net.minecraftforge.gradle.forge" version "2.0.2"
}
*/
version = "0.2.0"
version = "0.3.0"
group= "pers.towdium.justEnoughcalculation" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "je_calculation"
@@ -7,6 +7,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
@@ -23,6 +24,8 @@ import pers.towdium.justEnoughCalculation.network.packets.PacketCalculatorUpdate
import pers.towdium.justEnoughCalculation.network.packets.PacketRecipeUpdate;
import pers.towdium.justEnoughCalculation.network.packets.PacketSyncRecord;
import java.io.File;
/**
* @author Towdium
*/
@@ -33,6 +36,7 @@ public class JustEnoughCalculation {
public static Item itemCalculator = new ItemCalculator().setUnlocalizedName("itemCalculator");
public static SimpleNetworkWrapper networkWrapper;
public static Logger log = LogManager.getLogger(Reference.MODID);
public static Configuration config;
@SidedProxy(clientSide = "pers.towdium.justEnoughCalculation.network.ProxyClient", serverSide = "pers.towdium.justEnoughCalculation.network.ProxyServer")
public static IProxy proxy;
@@ -43,11 +47,15 @@ public class JustEnoughCalculation {
public static class Reference {
public static final String MODID = "je_calculation";
public static final String MODNAME = "Just Enough Calculation";
public static final String VERSION = "0.2.0";
public static final String VERSION = "0.3.0";
}
@Mod.EventHandler
public static void preInit(FMLPreInitializationEvent event){
config = new Configuration(new File(event.getModConfigurationDirectory(), "JustEnoughCalculation" +".cfg"), Reference.VERSION);
config.load();
config.get("General", "EnableInventoryCheck", true, "Set to false to disable auto inventory check");
config.save();
GameRegistry.registerItem(itemCalculator,itemCalculator.getUnlocalizedName().substring(5));
networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MODID);
networkWrapper.registerMessage(PacketCalculatorUpdate.class, PacketCalculatorUpdate.class, 1, Side.SERVER);
@@ -11,6 +11,7 @@ import java.util.List;
* This is calculating core v3.0, I call it global coordinating calculation XD.
* The procudure might be more complex, but can avoid some unexpected results.
*/
public class Calculator {
List<CostRecord> costRecords;
@@ -46,6 +47,6 @@ public class Calculator {
protected long getCount(ItemRecord itemRecord, Recipe recipe){
long a = recipe.getOutputAmount(itemRecord.toItemStack());
return (long) ((double)itemRecord.amount/a + 0.5f);
return (long)Math.ceil(itemRecord.amount/(double)a);
}
}
@@ -39,7 +39,9 @@ public class CostRecord{
ItemRecord record = new ItemRecord(itemStack, count);
record.approx = b;
input.add(record);
catalyst.add(record.copy());
record = new ItemRecord(itemStack);
record.approx = b;
catalyst.add(record);
}
}
}
@@ -159,8 +161,10 @@ public class CostRecord{
}
}
ItemRecord buffer = itemRecord.copy();
buffer.amount=0;
builder.add(buffer.toItemStack());
//buffer.amount=0;
ItemStack itemStack = buffer.toItemStack();
//itemStack.getTagCompound().setBoolean("mark", true);
builder.add(itemStack);
}
}
return builder.build();
@@ -31,7 +31,7 @@ public class ItemStackWrapper {
return "";
}
long l = itemStack.getTagCompound().getLong("amount");
if(l == 0){
if(l == 0 && itemStack.stackSize == 0){
return "";
}
int i = itemStack.getTagCompound().getInteger("percentage");
@@ -249,7 +249,7 @@ public class ItemStackWrapper {
}
public static boolean rightClick(ItemStack itemStack, boolean doChange){
if(itemStack == null || (itemStack.hasTagCompound() && (itemStack.getTagCompound().getInteger("percentage") == 1 || itemStack.getTagCompound().getInteger("percentage") == 0))){
if(itemStack == null){
return false;
}else {
if(doChange){
@@ -31,8 +31,7 @@ public abstract class GuiJustEnoughCalculation extends GuiContainer {
@Override
protected void handleMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType) {
if (slotIn != null)
{
if (slotIn != null) {
slotId = slotIn.slotNumber;
}
mc.thePlayer.openContainer.slotClick(slotId, clickedButton, clickType, mc.thePlayer);
@@ -93,6 +93,18 @@ public class GuiRecipe extends GuiTooltipScreen{
}
}
@Override
protected void handleMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType) {
boolean b = false;
if(slotIn != null){
b = slotIn.getHasStack();
}
super.handleMouseClick(slotIn, slotId, clickedButton, clickType);
if(slotIn != null && b && !slotIn.getHasStack()){
buttonList.get(slotIn.getSlotIndex()).displayString = "#";
}
}
public int getActiveSlot() {
return activeSlot;
}
@@ -106,14 +118,22 @@ public class GuiRecipe extends GuiTooltipScreen{
List<ItemStack> input = recipe.getInput();
for(int i=0; i<4; i++){
if(i<output.size()){
this.inventorySlots.getSlot(i).putStack(output.get(i));
ItemStack itemStack = output.get(i);
this.inventorySlots.getSlot(i).putStack(itemStack);
if(itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("percentage")){
buttonList.get(i).displayString = "%";
}
}else {
this.inventorySlots.getSlot(i).putStack(null);
}
}
for(int i=0; i<12; i++){
if(i<input.size()){
this.inventorySlots.getSlot(i+4).putStack(input.get(i));
ItemStack itemStack = input.get(i);
this.inventorySlots.getSlot(i+4).putStack(itemStack);
if(itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("percentage")){
buttonList.get(i+4).displayString = "%";
}
}else {
this.inventorySlots.getSlot(i+4).putStack(null);
}
@@ -227,7 +227,9 @@ public class GuiCalculator extends GuiTooltipScreen{
}
buttonLeft.enabled = page != 1;
buttonRight.enabled = page < total;
checkItem();
if(JustEnoughCalculation.config.get("General", "EnableInventoryCheck", true, "Set to false to disable auto inventory check").getBoolean()){
checkItem();
}
}
public int getActiveSlot() {
@@ -292,6 +294,12 @@ public class GuiCalculator extends GuiTooltipScreen{
}
protected void checkItem(){
if(mode != EnumMode.INPUT){
for(int i=0; i<36; i++){
items.put(i, 0);
}
return;
}
for(int i=0; i<36; i++){
ItemStack itemStack = inventorySlots.getSlot(i+1).getStack();
if(itemStack == null){