mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 01:24:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d11034e4aa | ||
|
|
cc64b09ad4 | ||
|
|
d5ebc02999 | ||
|
|
8415b657f2 | ||
|
|
f0099b728f | ||
|
|
1ceccddbd0 | ||
|
|
c875e8ed5d | ||
|
|
f3ee4f8694 | ||
|
|
c2437a8a13 | ||
|
|
e2f32ab767 | ||
|
|
d0c8c92863 | ||
|
|
a8c84cfcf9 | ||
|
|
8f8f6a05f7 | ||
|
|
721c8fd0ad | ||
|
|
01e43d8a18 |
No files matched your search
+1
-1
Submodule api/forestry updated: b3ffac04d0...5e44fe9c6a.
+2
-2
@@ -1,5 +1,5 @@
|
||||
mcversion=1.7.10
|
||||
forgeversion=10.13.4.1541-1.7.10
|
||||
forgeversion=10.13.4.1566-1.7.10
|
||||
version_major=4
|
||||
version_minor=2
|
||||
version_patch=1
|
||||
version_patch=3
|
||||
+1
-1
Submodule lang updated: 265a8e573a...cb5900228e.
@@ -17,6 +17,7 @@ import net.minecraft.item.Item;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
@@ -58,7 +59,7 @@ import forestry.plugins.PluginManager;
|
||||
name = "Forestry",
|
||||
version = Version.VERSION,
|
||||
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
|
||||
dependencies = "required-after:Forge@[10.13.4.1448,);"
|
||||
dependencies = "required-after:Forge@[10.13.4.1566,);"
|
||||
+ "after:Buildcraft|Core@[6.1.7,);"
|
||||
+ "after:ExtrabiomesXL;"
|
||||
+ "after:BiomesOPlenty;"
|
||||
@@ -85,7 +86,9 @@ public class Forestry {
|
||||
packetHandler = new PacketHandler();
|
||||
|
||||
// Register event handler
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandlerCore());
|
||||
EventHandlerCore eventHandlerCore = new EventHandlerCore();
|
||||
MinecraftForge.EVENT_BUS.register(eventHandlerCore);
|
||||
FMLCommonHandler.instance().bus().register(eventHandlerCore);
|
||||
MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler());
|
||||
|
||||
configFolder = new File(event.getModConfigurationDirectory(), "forestry");
|
||||
|
||||
@@ -20,7 +20,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
@@ -112,7 +111,11 @@ public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implement
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
BeeManager.beeRoot.syncBreedingTrackerToPlayer(player);
|
||||
return new ContainerMinecartBeehouse(player.inventory, this, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdOfEntity() {
|
||||
return getEntityId();
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.DefaultBeeListener;
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
@@ -97,7 +96,11 @@ public class EntityMinecartBeehouse extends EntityMinecartBeeHousingBase {
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
BeeManager.beeRoot.syncBreedingTrackerToPlayer(player);
|
||||
return new ContainerMinecartBeehouse(player.inventory, this, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdOfEntity() {
|
||||
return getEntityId();
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,6 @@ package forestry.apiculture.genetics;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IApiaristTracker;
|
||||
@@ -27,11 +25,7 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
|
||||
|
||||
/** Required for creation from map storage */
|
||||
public ApiaristTracker(String s) {
|
||||
this(s, null);
|
||||
}
|
||||
|
||||
public ApiaristTracker(String s, GameProfile player) {
|
||||
super(s, player);
|
||||
super(s);
|
||||
}
|
||||
|
||||
private int queensTotal = 0;
|
||||
|
||||
@@ -328,10 +328,13 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
// Create a tracker if there is none yet.
|
||||
if (tracker == null) {
|
||||
tracker = new ApiaristTracker(filename, player);
|
||||
tracker = new ApiaristTracker(filename);
|
||||
world.setItemData(filename, tracker);
|
||||
}
|
||||
|
||||
tracker.setUsername(player);
|
||||
tracker.setWorld(world);
|
||||
|
||||
return tracker;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,12 @@ package forestry.apiculture.genetics.alleles;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
@@ -58,8 +61,8 @@ public class AlleleEffectFertile extends AlleleEffectThrottled {
|
||||
|
||||
private static boolean tryTickColumn(World world, int x, int z, int maxY, int minY) {
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block.getTickRandomly() && (block instanceof IGrowable || block instanceof IPlantable)) {
|
||||
world.scheduleBlockUpdate(x, y, z, block, 5);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ package forestry.apiculture.items;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.gui.GuiBeealyzer;
|
||||
import forestry.apiculture.inventory.ItemInventoryBeealyzer;
|
||||
@@ -33,7 +32,6 @@ public class ItemBeealyzer extends ItemWithGui {
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
BeeManager.beeRoot.syncBreedingTrackerToPlayer(player);
|
||||
ItemInventoryBeealyzer inventory = new ItemInventoryBeealyzer(player, heldItem);
|
||||
return new ContainerAlyzer(inventory, player);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ package forestry.apiculture.items;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.gui.ContainerImprinter;
|
||||
import forestry.apiculture.gui.GuiImprinter;
|
||||
@@ -32,7 +31,6 @@ public class ItemImprinter extends ItemWithGui {
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
BeeManager.beeRoot.syncBreedingTrackerToPlayer(player);
|
||||
return new ContainerImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem));
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
@@ -195,7 +194,6 @@ public abstract class TileAlveary extends MultiblockTileEntityForestry<Multibloc
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
BeeManager.beeRoot.syncBreedingTrackerToPlayer(player);
|
||||
return new ContainerAlveary(player.inventory, this);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
@@ -96,7 +95,6 @@ public class TileApiary extends TileBeeHousingBase implements IApiary {
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
BeeManager.beeRoot.syncBreedingTrackerToPlayer(player);
|
||||
return new ContainerBeeHousing(player.inventory, this, true);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import java.util.Collections;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.DefaultBeeListener;
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
@@ -62,7 +61,6 @@ public class TileBeehouse extends TileBeeHousingBase {
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
BeeManager.beeRoot.syncBreedingTrackerToPlayer(player);
|
||||
return new ContainerBeeHousing(player.inventory, this, false);
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,6 @@ package forestry.arboriculture.genetics;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.arboriculture.IArboristTracker;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
@@ -24,11 +22,7 @@ public class ArboristTracker extends BreedingTracker implements IArboristTracker
|
||||
|
||||
/** Required for creation from map storage */
|
||||
public ArboristTracker(String s) {
|
||||
this(s, null);
|
||||
}
|
||||
|
||||
public ArboristTracker(String s, GameProfile player) {
|
||||
super(s, player);
|
||||
super(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -272,10 +272,13 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot {
|
||||
|
||||
// Create a tracker if there is none yet.
|
||||
if (tracker == null) {
|
||||
tracker = new ArboristTracker(filename, player);
|
||||
tracker = new ArboristTracker(filename);
|
||||
world.setItemData(filename, tracker);
|
||||
}
|
||||
|
||||
tracker.setUsername(player);
|
||||
tracker.setWorld(world);
|
||||
|
||||
return tracker;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,15 +10,23 @@
|
||||
******************************************************************************/
|
||||
package forestry.core;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.errors.ErrorStateRegistry;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.plugins.PluginManager;
|
||||
@@ -43,6 +51,18 @@ public class EventHandlerCore {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void handlePlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
EntityPlayer player = event.player;
|
||||
if (player != null) {
|
||||
Collection<ISpeciesRoot> speciesRoots = AlleleManager.alleleRegistry.getSpeciesRoot().values();
|
||||
for (ISpeciesRoot speciesRoot : speciesRoots) {
|
||||
IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.getEntityWorld(), player.getGameProfile());
|
||||
breedingTracker.synchToPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void handleWorldLoad(WorldEvent.Load event) {
|
||||
for (ISaveEventHandler handler : PluginManager.saveEventHandlers) {
|
||||
|
||||
@@ -49,11 +49,19 @@ public final class FluidHelper {
|
||||
FluidStack liquid = getFluidStackInContainer(current);
|
||||
|
||||
if (fill && liquid != null) {
|
||||
int used = tank.fill(side, liquid, true);
|
||||
int canUseAmount = tank.fill(side, liquid, false);
|
||||
if (canUseAmount == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (used > 0) {
|
||||
ItemStack drainedContainer = getDrainedContainer(current, canUseAmount);
|
||||
if (ItemStackUtil.isIdenticalItem(current, drainedContainer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int usedAmount = tank.fill(side, liquid, true);
|
||||
if (usedAmount > 0) {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
ItemStack drainedContainer = getDrainedContainer(current, used);
|
||||
if (current.stackSize > 1) {
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
if (drainedContainer != null && !player.inventory.addItemStackToInventory(drainedContainer)) {
|
||||
|
||||
@@ -32,7 +32,7 @@ import forestry.core.utils.StringUtil;
|
||||
*/
|
||||
public class FilteredTank extends StandardTank {
|
||||
|
||||
private final Set<Integer> filters = new HashSet<>(); // FluidIDs
|
||||
private final Set<String> filters = new HashSet<>(); // FluidNames
|
||||
|
||||
public FilteredTank(int capacity, Fluid... filters) {
|
||||
this(capacity, Arrays.asList(filters), null);
|
||||
@@ -50,7 +50,7 @@ public class FilteredTank extends StandardTank {
|
||||
public void setFilters(Collection<Fluid> filters) {
|
||||
this.filters.clear();
|
||||
for (Fluid fluid : filters) {
|
||||
this.filters.add(fluid.getID());
|
||||
this.filters.add(fluid.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,14 +64,14 @@ public class FilteredTank extends StandardTank {
|
||||
|
||||
@Override
|
||||
public boolean accepts(Fluid fluid) {
|
||||
return filters.contains(fluid.getID());
|
||||
return filters.contains(fluid.getName());
|
||||
}
|
||||
|
||||
private boolean liquidMatchesFilter(FluidStack resource) {
|
||||
if (resource == null || filters == null) {
|
||||
return false;
|
||||
}
|
||||
return filters.contains(resource.getFluid().getID());
|
||||
return filters.contains(resource.getFluid().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,8 +83,8 @@ public class FilteredTank extends StandardTank {
|
||||
|
||||
toolTip.clear();
|
||||
if (Proxies.common.isShiftDown() || filters.size() < 5) {
|
||||
for (Integer filterId : filters) {
|
||||
Fluid fluidFilter = FluidRegistry.getFluid(filterId);
|
||||
for (String filterName : filters) {
|
||||
Fluid fluidFilter = FluidRegistry.getFluid(filterName);
|
||||
EnumRarity rarity = fluidFilter.getRarity();
|
||||
if (rarity == null) {
|
||||
rarity = EnumRarity.common;
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.genetics;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
@@ -18,11 +20,13 @@ import java.util.Set;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSavedData;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
import forestry.api.core.ForestryEvent;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
@@ -31,7 +35,7 @@ import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.network.packets.PacketGenomeTrackerUpdate;
|
||||
import forestry.core.network.packets.PacketGenomeTrackerSync;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class BreedingTracker extends WorldSavedData implements IBreedingTracker {
|
||||
@@ -44,6 +48,7 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin
|
||||
private static final String RESEARCHED_KEY = "RD";
|
||||
private static final String MODE_NAME_KEY = "BMS";
|
||||
private static final String MUTATION_FORMAT = "%s-%s=%s";
|
||||
private static final Collection<String> emptyStringCollection = Collections.emptyList();
|
||||
|
||||
public static final String TYPE_KEY = "TYPE";
|
||||
|
||||
@@ -52,13 +57,23 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin
|
||||
private final Set<String> researchedMutations = new HashSet<>();
|
||||
private String modeName;
|
||||
|
||||
private final GameProfile username;
|
||||
@Nullable
|
||||
private GameProfile username;
|
||||
@Nullable
|
||||
private World world;
|
||||
|
||||
protected BreedingTracker(String s, GameProfile username) {
|
||||
protected BreedingTracker(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public void setUsername(@Nullable GameProfile username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setWorld(@Nullable World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModeName() {
|
||||
return modeName;
|
||||
@@ -85,14 +100,31 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin
|
||||
|
||||
@Override
|
||||
public void synchToPlayer(EntityPlayer player) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
if (player instanceof EntityPlayerMP && !(player instanceof FakePlayer)) {
|
||||
IBreedingTracker breedingTracker = getBreedingTracker(player);
|
||||
String modeName = breedingTracker.getModeName();
|
||||
setModeName(modeName);
|
||||
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
encodeToNBT(nbttagcompound);
|
||||
Proxies.net.sendToPlayer(new PacketGenomeTrackerUpdate(nbttagcompound), (EntityPlayerMP) player);
|
||||
PacketGenomeTrackerSync packet = new PacketGenomeTrackerSync(nbttagcompound);
|
||||
Proxies.net.sendToPlayer(packet, player);
|
||||
}
|
||||
}
|
||||
|
||||
private void syncToPlayer(Collection<String> discoveredSpecies, Collection<String> discoveredMutations, Collection<String> researchedMutations) {
|
||||
if (world != null && username != null && username.getName() != null) {
|
||||
EntityPlayer player = world.getPlayerEntityByName(username.getName());
|
||||
if (player instanceof EntityPlayerMP && !(player instanceof FakePlayer)) {
|
||||
IBreedingTracker breedingTracker = getBreedingTracker(player);
|
||||
String modeName = breedingTracker.getModeName();
|
||||
setModeName(modeName);
|
||||
|
||||
NBTTagCompound nbtTagCompound = new NBTTagCompound();
|
||||
writeToNBT(nbtTagCompound, discoveredSpecies, discoveredMutations, researchedMutations);
|
||||
PacketGenomeTrackerSync packet = new PacketGenomeTrackerSync(nbtTagCompound);
|
||||
Proxies.net.sendToPlayer(packet, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,20 +153,22 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
if (modeName != null && !modeName.isEmpty()) {
|
||||
nbttagcompound.setString(MODE_NAME_KEY, modeName);
|
||||
}
|
||||
|
||||
nbttagcompound.setString(TYPE_KEY, speciesRootUID());
|
||||
|
||||
writeValuesToNBT(nbttagcompound, discoveredSpecies, SPECIES_COUNT_KEY, SPECIES_KEY);
|
||||
writeValuesToNBT(nbttagcompound, discoveredMutations, MUTATIONS_COUNT_KEY, MUTATIONS_KEY);
|
||||
writeValuesToNBT(nbttagcompound, researchedMutations, RESEARCHED_COUNT_KEY, RESEARCHED_KEY);
|
||||
writeToNBT(nbttagcompound, discoveredSpecies, discoveredMutations, researchedMutations);
|
||||
}
|
||||
|
||||
private static void readValuesFromNBT(NBTTagCompound nbttagcompound, Collection<String> values, String countKey, String key) {
|
||||
values.clear();
|
||||
private void writeToNBT(NBTTagCompound nbtTagCompound, Collection<String> discoveredSpecies, Collection<String> discoveredMutations, Collection<String> researchedMutations) {
|
||||
if (modeName != null && !modeName.isEmpty()) {
|
||||
nbtTagCompound.setString(MODE_NAME_KEY, modeName);
|
||||
}
|
||||
|
||||
nbtTagCompound.setString(TYPE_KEY, speciesRootUID());
|
||||
|
||||
writeValuesToNBT(nbtTagCompound, discoveredSpecies, SPECIES_COUNT_KEY, SPECIES_KEY);
|
||||
writeValuesToNBT(nbtTagCompound, discoveredMutations, MUTATIONS_COUNT_KEY, MUTATIONS_KEY);
|
||||
writeValuesToNBT(nbtTagCompound, researchedMutations, RESEARCHED_COUNT_KEY, RESEARCHED_KEY);
|
||||
}
|
||||
|
||||
private static void readValuesFromNBT(NBTTagCompound nbttagcompound, Set<String> values, String countKey, String key) {
|
||||
if (nbttagcompound.hasKey(countKey)) {
|
||||
final int count = nbttagcompound.getInteger(countKey);
|
||||
for (int i = 0; i < count; i++) {
|
||||
@@ -175,13 +209,15 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin
|
||||
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(speciesRootUID());
|
||||
ForestryEvent event = new ForestryEvent.MutationDiscovered(speciesRoot, username, mutation, this);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
syncToPlayer(emptyStringCollection, Collections.singleton(mutationString), emptyStringCollection);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDiscovered(IMutation mutation) {
|
||||
String mutationString = getMutationString(mutation);
|
||||
return discoveredMutations.contains(mutationString);
|
||||
return discoveredMutations.contains(mutationString) || researchedMutations.contains(mutationString);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,6 +244,8 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin
|
||||
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(speciesRootUID());
|
||||
ForestryEvent event = new ForestryEvent.SpeciesDiscovered(speciesRoot, username, species, this);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
syncToPlayer(Collections.singleton(species.getUID()), emptyStringCollection, emptyStringCollection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,6 +257,8 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin
|
||||
markDirty();
|
||||
|
||||
registerMutation(mutation);
|
||||
|
||||
syncToPlayer(emptyStringCollection, emptyStringCollection, Collections.singleton(mutationString));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -163,14 +162,6 @@ public abstract class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory>
|
||||
textLayout.newLine();
|
||||
textLayout.drawLine("IV : " + StringUtil.localize("gui.evolution"), COLUMN_0 + 4);
|
||||
|
||||
textLayout.newLine();
|
||||
|
||||
String mode = breedingTracker.getModeName();
|
||||
if (mode != null && !mode.isEmpty()) {
|
||||
String rules = StringUtil.localize(guiName + ".behaviour") + ": " + WordUtils.capitalize(mode);
|
||||
textLayout.drawCenteredLine(rules, 8, 208, fontColor.get(guiName + ".binomial"));
|
||||
}
|
||||
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
@@ -278,7 +269,7 @@ public abstract class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory>
|
||||
x += columnWidth;
|
||||
if (x >= columnWidth * 4) {
|
||||
x = 0;
|
||||
textLayout.newLine();
|
||||
textLayout.newLine(16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,7 +281,7 @@ public abstract class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory>
|
||||
ItemStack partnerBee = iconStacks.get(combination.getPartner(species).getUID());
|
||||
widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), partnerBee));
|
||||
|
||||
drawProbabilityArrow(combination.getBaseChance(), guiLeft + x + 18, guiTop + textLayout.getLineY() + 4);
|
||||
drawProbabilityArrow(combination, guiLeft + x + 18, guiTop + textLayout.getLineY() + 4);
|
||||
|
||||
IAllele result = combination.getTemplate()[EnumBeeChromosome.SPECIES.ordinal()];
|
||||
ItemStack resultBee = iconStacks.get(result.getUID());
|
||||
@@ -301,7 +292,7 @@ public abstract class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory>
|
||||
|
||||
drawQuestionMark(guiLeft + x, guiTop + textLayout.getLineY());
|
||||
|
||||
drawProbabilityArrow(combination.getBaseChance(), guiLeft + x + 18, guiTop + textLayout.getLineY() + 4);
|
||||
drawProbabilityArrow(combination, guiLeft + x + 18, guiTop + textLayout.getLineY() + 4);
|
||||
|
||||
drawQuestionMark(guiLeft + x + 32, guiTop + textLayout.getLineY());
|
||||
}
|
||||
@@ -311,7 +302,8 @@ public abstract class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory>
|
||||
drawTexturedModalRect(x, y, 78, 240, 16, 16);
|
||||
}
|
||||
|
||||
private void drawProbabilityArrow(float chance, int x, int y) {
|
||||
private void drawProbabilityArrow(IMutation combination, int x, int y) {
|
||||
float chance = combination.getBaseChance();
|
||||
int line = 247;
|
||||
int column = 100;
|
||||
switch (EnumMutateChance.rateChance(chance)) {
|
||||
@@ -339,6 +331,12 @@ public abstract class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory>
|
||||
// Probability arrow
|
||||
Proxies.render.bindTexture(textureFile);
|
||||
drawTexturedModalRect(x, y, column, line, 15, 9);
|
||||
|
||||
boolean researched = breedingTracker.isResearched(combination);
|
||||
if (researched) {
|
||||
fontRendererObj.drawString("+", x + 9, y + 1, 0);
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawToleranceInfo(IAlleleTolerance toleranceAllele, int x) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class GuiHandler implements IGuiHandler {
|
||||
|
||||
public static void openGui(EntityPlayer entityplayer, IGuiHandlerEntity guiHandler, short data) {
|
||||
int guiData = encodeGuiData(guiHandler, data);
|
||||
entityplayer.openGui(ForestryAPI.instance, guiData, entityplayer.worldObj, guiHandler.getEntityId(), 0, 0);
|
||||
entityplayer.openGui(ForestryAPI.instance, guiData, entityplayer.worldObj, guiHandler.getIdOfEntity(), 0, 0);
|
||||
}
|
||||
|
||||
public static void openGui(EntityPlayer entityplayer, IGuiHandlerItem guiHandler) {
|
||||
|
||||
@@ -28,9 +28,6 @@ import forestry.core.gui.tooltips.ToolTipLine;
|
||||
public class GuiUtil {
|
||||
public static void drawItemStack(GuiForestry gui, ItemStack stack, int xPos, int yPos) {
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
RenderItem itemRender = GuiForestry.getItemRenderer();
|
||||
|
||||
@@ -17,5 +17,6 @@ public interface IGuiHandlerEntity extends IGuiHandlerForestry {
|
||||
|
||||
Object getContainer(EntityPlayer player, int data);
|
||||
|
||||
int getEntityId();
|
||||
// can't be named getEntityId() for obfuscation reasons
|
||||
int getIdOfEntity();
|
||||
}
|
||||
@@ -22,10 +22,10 @@ public class ItemRegistryFluids extends ItemRegistry {
|
||||
public final ItemLiquidContainer waxCapsuleEmpty;
|
||||
public final ItemLiquidContainer refractoryEmpty;
|
||||
|
||||
private final Table<EnumContainerType, Integer, ItemLiquidContainer> containers = HashBasedTable.create();
|
||||
private final Table<EnumContainerType, String, ItemLiquidContainer> containers = HashBasedTable.create();
|
||||
|
||||
public ItemLiquidContainer getContainer(EnumContainerType type, Fluids fluid) {
|
||||
return containers.get(type, fluid.getFluid().getID());
|
||||
return containers.get(type, fluid.getFluid().getName());
|
||||
}
|
||||
|
||||
public ItemRegistryFluids() {
|
||||
@@ -45,7 +45,7 @@ public class ItemRegistryFluids extends ItemRegistry {
|
||||
String name = type.getContainerNameKey() + fluidType.getContainerNameKey();
|
||||
registerItem(liquidContainer, name);
|
||||
|
||||
containers.put(type, fluidType.getFluid().getID(), liquidContainer);
|
||||
containers.put(type, fluidType.getFluid().getName(), liquidContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import forestry.core.network.packets.PacketChipsetClick;
|
||||
import forestry.core.network.packets.PacketErrorUpdate;
|
||||
import forestry.core.network.packets.PacketErrorUpdateEntity;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.network.packets.PacketGenomeTrackerUpdate;
|
||||
import forestry.core.network.packets.PacketGenomeTrackerSync;
|
||||
import forestry.core.network.packets.PacketGuiEnergy;
|
||||
import forestry.core.network.packets.PacketGuiLayoutSelect;
|
||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||
@@ -47,7 +47,7 @@ public class PacketRegistryCore extends PacketRegistry {
|
||||
registerClientPacket(new PacketItemStackDisplay());
|
||||
registerClientPacket(new PacketFXSignal());
|
||||
registerClientPacket(new PacketTankLevelUpdate());
|
||||
registerClientPacket(new PacketGenomeTrackerUpdate());
|
||||
registerClientPacket(new PacketGenomeTrackerSync());
|
||||
|
||||
registerServerPacket(new PacketGuiSelectRequest());
|
||||
registerServerPacket(new PacketPipetteClick());
|
||||
|
||||
+3
-3
@@ -27,12 +27,12 @@ import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketGenomeTrackerUpdate extends PacketNBT implements IForestryPacketClient {
|
||||
public class PacketGenomeTrackerSync extends PacketNBT implements IForestryPacketClient {
|
||||
|
||||
public PacketGenomeTrackerUpdate() {
|
||||
public PacketGenomeTrackerSync() {
|
||||
}
|
||||
|
||||
public PacketGenomeTrackerUpdate(NBTTagCompound nbtTagCompound) {
|
||||
public PacketGenomeTrackerSync(NBTTagCompound nbtTagCompound) {
|
||||
super(nbtTagCompound);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -215,12 +214,12 @@ public abstract class RecipeUtil {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addRecipe(ItemStack itemstack, Object... obj) {
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(itemstack, obj));
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedRecipeCustom(itemstack, obj));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void addPriorityRecipe(ItemStack itemStack, Object... obj) {
|
||||
CraftingManager.getInstance().getRecipeList().add(0, new ShapedOreRecipe(itemStack, obj));
|
||||
CraftingManager.getInstance().getRecipeList().add(0, new ShapedRecipeCustom(itemStack, obj));
|
||||
}
|
||||
|
||||
public static void addShapelessRecipe(Item item, Object... obj) {
|
||||
|
||||
@@ -10,22 +10,106 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.recipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
import forestry.api.recipes.IDescriptiveRecipe;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class ShapedRecipeCustom extends ShapedOreRecipe implements IDescriptiveRecipe {
|
||||
private final int width;
|
||||
private final int height;
|
||||
//Added in for future ease of change, but hard coded for now.
|
||||
private static final int MAX_CRAFT_GRID_WIDTH = 3;
|
||||
private static final int MAX_CRAFT_GRID_HEIGHT = 3;
|
||||
|
||||
public ShapedRecipeCustom(int width, int height, ItemStack product, Object... ingredients) {
|
||||
super(product, ingredients);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
private ItemStack output = null;
|
||||
private Object[] input = null;
|
||||
private int width;
|
||||
private int height;
|
||||
private boolean mirrored = true;
|
||||
|
||||
public ShapedRecipeCustom(ItemStack result, Object... recipe) {
|
||||
super(result, recipe);
|
||||
output = result.copy();
|
||||
|
||||
String shape = "";
|
||||
int idx = 0;
|
||||
|
||||
if (recipe[idx] instanceof Boolean) {
|
||||
mirrored = (Boolean) recipe[idx];
|
||||
if (recipe[idx + 1] instanceof Object[]) {
|
||||
recipe = (Object[]) recipe[idx + 1];
|
||||
} else {
|
||||
idx = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (recipe[idx] instanceof String[]) {
|
||||
String[] parts = ((String[]) recipe[idx++]);
|
||||
|
||||
for (String s : parts) {
|
||||
width = s.length();
|
||||
shape += s;
|
||||
}
|
||||
|
||||
height = parts.length;
|
||||
} else {
|
||||
while (recipe[idx] instanceof String) {
|
||||
String s = (String) recipe[idx++];
|
||||
shape += s;
|
||||
width = s.length();
|
||||
height++;
|
||||
}
|
||||
}
|
||||
|
||||
if (width * height != shape.length()) {
|
||||
String ret = "Invalid shaped ore recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
|
||||
HashMap<Character, Object> itemMap = new HashMap<Character, Object>();
|
||||
|
||||
for (; idx < recipe.length; idx += 2) {
|
||||
Character chr = (Character) recipe[idx];
|
||||
Object in = recipe[idx + 1];
|
||||
|
||||
if (in instanceof ItemStack) {
|
||||
itemMap.put(chr, ((ItemStack) in).copy());
|
||||
} else if (in instanceof Item) {
|
||||
itemMap.put(chr, new ItemStack((Item) in));
|
||||
} else if (in instanceof Block) {
|
||||
itemMap.put(chr, new ItemStack((Block) in, 1, OreDictionary.WILDCARD_VALUE));
|
||||
} else if (in instanceof String) {
|
||||
itemMap.put(chr, OreDictionary.getOres((String) in));
|
||||
} else {
|
||||
String ret = "Invalid shaped ore recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
|
||||
input = new Object[width * height];
|
||||
int x = 0;
|
||||
for (char chr : shape.toCharArray()) {
|
||||
input[x++] = itemMap.get(chr);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,24 +138,66 @@ public class ShapedRecipeCustom extends ShapedOreRecipe implements IDescriptiveR
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ShapedRecipeCustom createShapedRecipe(ItemStack product, Object... materials) {
|
||||
int index = 0;
|
||||
int columns = 0;
|
||||
int rows = 0;
|
||||
if (materials[index] instanceof String[]) {
|
||||
String as[] = (String[]) materials[index];
|
||||
for (String pattern : as) {
|
||||
rows++;
|
||||
columns = pattern.length();
|
||||
}
|
||||
} else {
|
||||
while (materials[index] instanceof String) {
|
||||
String pattern = (String) materials[index++];
|
||||
rows++;
|
||||
columns = pattern.length();
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inv, World world) {
|
||||
for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) {
|
||||
for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) {
|
||||
if (checkMatch(inv, x, y, false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mirrored && checkMatch(inv, x, y, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ShapedRecipeCustom(columns, rows, product, materials);
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) {
|
||||
for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) {
|
||||
for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) {
|
||||
int subX = x - startX;
|
||||
int subY = y - startY;
|
||||
Object target = null;
|
||||
|
||||
if (subX >= 0 && subY >= 0 && subX < width && subY < height) {
|
||||
if (mirror) {
|
||||
target = input[width - subX - 1 + subY * width];
|
||||
} else {
|
||||
target = input[subX + subY * width];
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack slot = inv.getStackInRowAndColumn(x, y);
|
||||
|
||||
if (target instanceof ItemStack) {
|
||||
if (!ItemStackUtil.isCraftingEquivalent((ItemStack) target, slot)) {
|
||||
return false;
|
||||
}
|
||||
} else if (target instanceof ArrayList) {
|
||||
boolean matched = false;
|
||||
|
||||
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) target).iterator();
|
||||
while (itr.hasNext() && !matched) {
|
||||
matched = ItemStackUtil.isCraftingEquivalent(itr.next(), slot);
|
||||
}
|
||||
|
||||
if (!matched) {
|
||||
return false;
|
||||
}
|
||||
} else if (target == null && slot != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static ShapedRecipeCustom createShapedRecipe(ItemStack product, Object... materials) {
|
||||
return new ShapedRecipeCustom(product, materials);
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,6 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, int page) {
|
||||
speciesRoot.syncBreedingTrackerToPlayer(player);
|
||||
return new ContainerNaturalistInventory(player.inventory, this, page);
|
||||
}
|
||||
}
|
||||
@@ -236,10 +236,13 @@ public class ButterflyHelper extends SpeciesRoot implements IButterflyRoot {
|
||||
|
||||
// Create a tracker if there is none yet.
|
||||
if (tracker == null) {
|
||||
tracker = new LepidopteristTracker(filename, player);
|
||||
tracker = new LepidopteristTracker(filename);
|
||||
world.setItemData(filename, tracker);
|
||||
}
|
||||
|
||||
tracker.setUsername(player);
|
||||
tracker.setWorld(world);
|
||||
|
||||
return tracker;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@ package forestry.lepidopterology.genetics;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.lepidopterology.ButterflyManager;
|
||||
@@ -25,11 +23,7 @@ public class LepidopteristTracker extends BreedingTracker implements ILepidopter
|
||||
|
||||
/** Required for creation from map storage */
|
||||
public LepidopteristTracker(String s) {
|
||||
this(s, null);
|
||||
}
|
||||
|
||||
public LepidopteristTracker(String s, GameProfile player) {
|
||||
super(s, player);
|
||||
super(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Executable → Regular
+18
-11
@@ -10,31 +10,38 @@
|
||||
******************************************************************************/
|
||||
package forestry.mail;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.mail.gui.GuiMailboxInfo;
|
||||
import forestry.mail.network.packets.PacketPOBoxInfoRequest;
|
||||
|
||||
public class TickHandlerMailClient {
|
||||
private static final int THROTTLE_TIME_MS = 10000;
|
||||
private long lastInfoRequestTime;
|
||||
import forestry.mail.network.packets.PacketPOBoxInfoUpdate;
|
||||
|
||||
public class EventHandlerMailAlert {
|
||||
@SubscribeEvent
|
||||
public void onRenderTick(TickEvent.RenderTickEvent event) {
|
||||
if (event.phase != Phase.END) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GuiMailboxInfo.instance.hasPOBoxInfo()) {
|
||||
if (Minecraft.getMinecraft().theWorld != null && GuiMailboxInfo.instance.hasPOBoxInfo()) {
|
||||
GuiMailboxInfo.instance.render();
|
||||
} else {
|
||||
long time = System.currentTimeMillis();
|
||||
if (time - lastInfoRequestTime > THROTTLE_TIME_MS) {
|
||||
Proxies.net.sendToServer(new PacketPOBoxInfoRequest());
|
||||
lastInfoRequestTime = time;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void handlePlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
EntityPlayer player = event.player;
|
||||
if (player != null) {
|
||||
MailAddress address = new MailAddress(player.getGameProfile());
|
||||
POBox pobox = PostRegistry.getOrCreatePOBox(player.worldObj, address);
|
||||
if (pobox != null) {
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfoUpdate(pobox.getPOBoxInfo()), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ import forestry.api.mail.ITradeStation;
|
||||
import forestry.api.mail.PostManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
import forestry.mail.network.packets.PacketPOBoxInfoResponse;
|
||||
import forestry.mail.network.packets.PacketPOBoxInfoUpdate;
|
||||
import forestry.plugins.PluginMail;
|
||||
|
||||
public class PostRegistry implements IPostRegistry {
|
||||
@@ -75,7 +75,7 @@ public class PostRegistry implements IPostRegistry {
|
||||
|
||||
EntityPlayer player = PlayerUtil.getPlayer(world, address.getPlayerProfile());
|
||||
if (player != null) {
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), player);
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfoUpdate(pobox.getPOBoxInfo()), player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.mail.network.packets.PacketPOBoxInfoResponse;
|
||||
import forestry.mail.network.packets.PacketPOBoxInfoUpdate;
|
||||
|
||||
public class PostalCarrier implements IPostalCarrier {
|
||||
|
||||
@@ -88,7 +88,7 @@ public class PostalCarrier implements IPostalCarrier {
|
||||
} else {
|
||||
EntityPlayer player = PlayerUtil.getPlayer(world, recipient.getPlayerProfile());
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), (EntityPlayerMP) player);
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfoUpdate(pobox.getPOBoxInfo()), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
import forestry.mail.POBox;
|
||||
import forestry.mail.POBoxInfo;
|
||||
import forestry.mail.network.packets.PacketPOBoxInfoResponse;
|
||||
import forestry.mail.network.packets.PacketPOBoxInfoUpdate;
|
||||
import forestry.mail.tiles.TileMailbox;
|
||||
|
||||
public class ContainerMailbox extends ContainerTile<TileMailbox> {
|
||||
@@ -55,7 +55,7 @@ public class ContainerMailbox extends ContainerTile<TileMailbox> {
|
||||
if (SlotUtil.isSlotInRange(slotIndex, SLOT_LETTERS, SLOT_LETTERS_COUNT)) {
|
||||
if (!player.worldObj.isRemote && mailInventory != null) {
|
||||
POBoxInfo info = mailInventory.getPOBoxInfo();
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(info), player);
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfoUpdate(info), player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@ import forestry.core.network.PacketRegistry;
|
||||
import forestry.mail.network.packets.PacketLetterInfoRequest;
|
||||
import forestry.mail.network.packets.PacketLetterInfoResponse;
|
||||
import forestry.mail.network.packets.PacketLetterTextSet;
|
||||
import forestry.mail.network.packets.PacketPOBoxInfoRequest;
|
||||
import forestry.mail.network.packets.PacketPOBoxInfoResponse;
|
||||
import forestry.mail.network.packets.PacketPOBoxInfoUpdate;
|
||||
import forestry.mail.network.packets.PacketTraderAddressRequest;
|
||||
import forestry.mail.network.packets.PacketTraderAddressResponse;
|
||||
|
||||
@@ -24,11 +23,10 @@ public class PacketRegistryMail extends PacketRegistry {
|
||||
public void registerPackets() {
|
||||
registerServerPacket(new PacketLetterInfoRequest());
|
||||
registerServerPacket(new PacketTraderAddressRequest());
|
||||
registerServerPacket(new PacketPOBoxInfoRequest());
|
||||
registerServerPacket(new PacketLetterTextSet());
|
||||
|
||||
registerClientPacket(new PacketLetterInfoResponse());
|
||||
registerClientPacket(new PacketTraderAddressResponse());
|
||||
registerClientPacket(new PacketPOBoxInfoResponse());
|
||||
registerClientPacket(new PacketPOBoxInfoUpdate());
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.mail.network.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.mail.MailAddress;
|
||||
import forestry.mail.POBox;
|
||||
import forestry.mail.PostRegistry;
|
||||
|
||||
public class PacketPOBoxInfoRequest extends ForestryPacket implements IForestryPacketServer {
|
||||
|
||||
public PacketPOBoxInfoRequest() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketIdServer getPacketId() {
|
||||
return PacketIdServer.POBOX_INFO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
MailAddress address = new MailAddress(player.getGameProfile());
|
||||
POBox pobox = PostRegistry.getOrCreatePOBox(player.worldObj, address);
|
||||
if (pobox != null) {
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -22,14 +22,14 @@ import forestry.core.network.PacketIdClient;
|
||||
import forestry.mail.POBoxInfo;
|
||||
import forestry.mail.gui.GuiMailboxInfo;
|
||||
|
||||
public class PacketPOBoxInfoResponse extends ForestryPacket implements IForestryPacketClient {
|
||||
public class PacketPOBoxInfoUpdate extends ForestryPacket implements IForestryPacketClient {
|
||||
|
||||
public POBoxInfo poboxInfo;
|
||||
|
||||
public PacketPOBoxInfoResponse() {
|
||||
public PacketPOBoxInfoUpdate() {
|
||||
}
|
||||
|
||||
public PacketPOBoxInfoResponse(POBoxInfo info) {
|
||||
public PacketPOBoxInfoUpdate(POBoxInfo info) {
|
||||
this.poboxInfo = info;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,15 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.WeightedRandomChestContent;
|
||||
|
||||
import net.minecraftforge.common.ChestGenHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.FuelBurnTimeEvent;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import cpw.mods.fml.common.IFuelHandler;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
@@ -38,6 +42,7 @@ import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.api.storage.ICrateRegistry;
|
||||
import forestry.api.storage.StorageManager;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.VillageHandlerArboriculture;
|
||||
import forestry.arboriculture.WoodItemAccess;
|
||||
import forestry.arboriculture.blocks.BlockArboricultureType;
|
||||
@@ -119,6 +124,9 @@ public class PluginArboriculture extends ForestryPlugin {
|
||||
public void preInit() {
|
||||
super.preInit();
|
||||
|
||||
// register for FuelBurnTimeEvent
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
for (EnumWoodType woodType : EnumWoodType.VALUES) {
|
||||
WoodItemAccess.registerLog(blocks.logs, woodType, false);
|
||||
WoodItemAccess.registerPlanks(blocks.planks, woodType, false);
|
||||
@@ -411,11 +419,24 @@ public class PluginArboriculture extends ForestryPlugin {
|
||||
return 100;
|
||||
}
|
||||
|
||||
if (blocks.slabs == Block.getBlockFromItem(item)) {
|
||||
return 150;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void fuelBurnTimeEvent(FuelBurnTimeEvent fuelBurnTimeEvent) {
|
||||
Item item = fuelBurnTimeEvent.fuel.getItem();
|
||||
Block block = Block.getBlockFromItem(item);
|
||||
|
||||
if (block instanceof IWoodTyped) {
|
||||
IWoodTyped woodTypedBlock = (IWoodTyped) block;
|
||||
if (woodTypedBlock.isFireproof()) {
|
||||
fuelBurnTimeEvent.burnTime = 0;
|
||||
fuelBurnTimeEvent.setResult(Event.Result.DENY);
|
||||
} else if (blocks.slabs == block) {
|
||||
fuelBurnTimeEvent.burnTime = 150;
|
||||
fuelBurnTimeEvent.setResult(Event.Result.DENY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,10 +28,10 @@ import forestry.core.items.EnumElectronTube;
|
||||
import forestry.core.network.IPacketRegistry;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.tiles.MachineDefinition;
|
||||
import forestry.mail.EventHandlerMailAlert;
|
||||
import forestry.mail.PostRegistry;
|
||||
import forestry.mail.PostalCarrier;
|
||||
import forestry.mail.SaveEventHandlerMail;
|
||||
import forestry.mail.TickHandlerMailClient;
|
||||
import forestry.mail.blocks.BlockMailType;
|
||||
import forestry.mail.blocks.BlockRegistryMail;
|
||||
import forestry.mail.commands.CommandMail;
|
||||
@@ -67,7 +67,7 @@ public class PluginMail extends ForestryPlugin {
|
||||
PluginCore.rootCommand.addChildCommand(new CommandMail());
|
||||
|
||||
if (Config.mailAlertEnabled) {
|
||||
FMLCommonHandler.instance().bus().register(new TickHandlerMailClient());
|
||||
FMLCommonHandler.instance().bus().register(new EventHandlerMailAlert());
|
||||
}
|
||||
|
||||
blocks.mail.addDefinitions(
|
||||
|
||||
@@ -59,6 +59,7 @@ import forestry.plugins.compat.PluginImmersiveEngineering;
|
||||
import forestry.plugins.compat.PluginMagicalCrops;
|
||||
import forestry.plugins.compat.PluginNatura;
|
||||
import forestry.plugins.compat.PluginPlantMegaPack;
|
||||
import forestry.plugins.compat.PluginRotaryCraft;
|
||||
import forestry.plugins.compat.PluginWitchery;
|
||||
|
||||
public class PluginManager {
|
||||
@@ -116,6 +117,7 @@ public class PluginManager {
|
||||
MAGICALCROPS(new PluginMagicalCrops()),
|
||||
NATURA(new PluginNatura()),
|
||||
PLANTMEGAPACK(new PluginPlantMegaPack()),
|
||||
ROTARYCRAFT(new PluginRotaryCraft()),
|
||||
WITCHERY(new PluginWitchery());
|
||||
|
||||
static {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class PluginImmersiveEngineering extends ForestryPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRecipes() {
|
||||
protected void postInit() {
|
||||
|
||||
ItemStack hempSeed = GameRegistry.findItemStack(ImEng, "seed", 1);
|
||||
Block hempCrop = GameRegistry.findBlock(ImEng, "hemp");
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.plugins.compat;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.farming.Farmables;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.farming.logic.FarmableBasicFruit;
|
||||
import forestry.farming.logic.FarmableGenericCrop;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.Plugin;
|
||||
|
||||
@Plugin(pluginID = "RotaryCraft", name = "RotaryCraft", author = "Nirek", url = Constants.URL, unlocalizedDescription = "for.plugin.rotarycraft.description")
|
||||
public class PluginRotaryCraft extends ForestryPlugin {
|
||||
|
||||
private static final String RC = "RotaryCraft";
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return ModUtil.isModLoaded(RC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFailMessage() {
|
||||
return "RotaryCraft not found";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRecipes() {
|
||||
|
||||
ItemStack canolaSeed = GameRegistry.findItemStack(RC, "rotarycraft_item_canola", 1);
|
||||
Block canolaCrop = GameRegistry.findBlock(RC, "rotarycraft_block_canola");
|
||||
|
||||
int seedAmount = (ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed")/16);
|
||||
seedAmount = Math.max(seedAmount, 1); // Produce at least 1 mb.
|
||||
if (canolaSeed != null && canolaCrop != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{canolaSeed}, Fluids.SEEDOIL.getFluid(seedAmount));
|
||||
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(canolaSeed, canolaCrop, 9));
|
||||
Farmables.farmables.get("farmOrchard").add(new FarmableBasicFruit(canolaCrop, 9));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user