Compare commits

...
16 Commits
Author SHA1 Message Date
Martin Robertz 66e040d9b3 update 2025-11-04 22:44:09 +01:00
Worive 7f8c7ca5bc Rename attribute for more clarity 2025-11-04 18:26:07 +01:00
Worive e4daa5a796 Improve NetworkedInventory robustness
Replaced the hardcoded inventory re-check logic with a universal TileEntity validity check. By caching the TileEntity and using isInvalid(), conduits can now automatically detect when a connected block is broken or replaced, allowing them to reconnect seamlessly.
2025-11-02 10:50:55 +01:00
Martin Robertz a7acc7e224 update 2025-10-19 20:30:47 +02:00
Martin Robertz a59bb21e59 update 2025-10-12 20:30:55 +02:00
chochem 5b6c13ff0a Dont register several duplicate items in case of GTNH (#209) 2025-10-12 01:14:36 +01:00
Martin Robertz 6f8b6e2a9c update 2025-10-04 14:26:40 +02:00
TheYoingLadandMartin Robertz 479c8328b4 Added the ability for the farming station to plant Pam's nether seeds (#208)
Co-authored-by: Martin Robertz <[email protected]>
2025-10-04 12:24:54 +00:00
Wilhelm Schuster 0c23f4937d Handle mouse button keybinds (#204) 2025-09-25 19:55:57 +02:00
Wilhelm Schusterandgithub-actions[bot] cde2e4fa60 Fix crash when breaking Painted Glowstone placed by Better Builders Wand (#206)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-09-25 19:35:30 +02:00
Ranzu abbb6dc151 Update bauble slot background in capacitor ui (#203) 2025-09-25 15:20:59 +02:00
Martin Robertz b3def82cde update 2025-09-24 16:49:42 +02:00
EmperorSuper 8b4e7f7ec3 Cap the length of the baubles inventory (#202) 2025-09-24 11:10:22 +02:00
Alexdoru d69d77ecae fix NPE in BlockConduitBundle#onPlaySound (#201) 2025-07-25 08:21:32 +07:00
Dream Master a233f6ba30 update 2025-07-18 09:47:57 +07:00
boubou19andAlexdoru 581150178f Speed up forge event registration (#200)
Co-authored-by: Alexdoru <[email protected]>
2025-07-17 22:37:03 +00:00
32 changed files with 551 additions and 431 deletions

No files matched your search

+17 -16
View File
@@ -1,24 +1,24 @@
// Add your dependencies here
dependencies {
api('com.github.GTNewHorizons:EnderCore:0.4.8:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ForestryMC:4.10.14:dev')
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.7.64-GTNH:dev')
api("com.github.GTNewHorizons:GTNHLib:0.6.38:dev")
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.44:dev')
api('com.github.GTNewHorizons:EnderCore:0.5.0:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ForestryMC:4.11.2:dev')
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.8.26-GTNH:dev')
api("com.github.GTNewHorizons:GTNHLib:0.7.7:dev")
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.45:dev')
api('curse.maven:cofh-lib-220333:2388748') // https://www.curseforge.com/minecraft/mc-mods/cofh-lib/files/2388748
shadowImplementation('cglib:cglib-nodep:3.3.0')
api("com.github.GTNewHorizons:TinkersConstruct:1.13.40-GTNH:dev")
api("com.github.GTNewHorizons:TinkersConstruct:1.14.6-GTNH:dev")
compileOnly('com.github.GTNewHorizons:waila:1.8.12:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-660-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Baubles:1.0.4:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.395:dev') {transitive = false}
compileOnly("com.github.GTNewHorizons:ModularUI2:2.2.16-1.7.10:dev") {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.16.30:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:2.1.5-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Chisel:2.16.5-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.11.16-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:waila:1.9.7:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-729-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.2.2-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.95:dev') {transitive = false}
compileOnly("com.github.GTNewHorizons:ModularUI2:2.3.5-1.7.10:dev") {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.17.4:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:2.2.1-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Chisel:2.17.3-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.12.4-GTNH:api') {transitive = false}
compileOnly('curse.maven:minefactory-reloaded-66672:2366150') // https://www.curseforge.com/minecraft/mc-mods/minefactory-reloaded/files/2366150
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('curse.maven:ee3-65509:2305023') // https://www.curseforge.com/minecraft/mc-mods/ee3/files/2305023
@@ -26,5 +26,6 @@ dependencies {
compileOnly(rfg.deobf('curse.maven:mekanism-268560:2475797')) // https://www.curseforge.com/minecraft/mc-mods/mekanism/files/2475797
compileOnly(rfg.deobf('maven.modrinth:immibis-microblocks:59.1.2')) // https://modrinth.com/mod/immibis-microblocks/version/59.1.2
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta50:api') {transitive = false}
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta64:api') {transitive = false}
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.9:dev")
}
+9 -1
View File
@@ -96,7 +96,9 @@ usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
@@ -172,6 +174,12 @@ curseForgeRelations =
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
# runClientWorkingDirectory = run/client
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
# runServerWorkingDirectory = run/server
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -2
View File
@@ -114,7 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
@@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
Vendored
+2 -2
View File
@@ -70,11 +70,11 @@ goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.41'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.48'
}
@@ -213,6 +213,7 @@ public class EnderIO {
public static final boolean hasLwjgl3 = Loader.isModLoaded("lwjgl3ify");
public static final boolean hasGT5 = Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi");
public static final boolean hasHP = Loader.isModLoaded("hodgepodge");
// Materials
public static ItemCapacitor itemBasicCapacitor;
@@ -486,7 +487,9 @@ public class EnderIO {
itemGrindingBall = ItemGrindingBall.create();
itemAlloyEndergy = ItemAlloyEndergy.create();
itemGrindingBallEndergy = ItemGrindingBallEndergy.create();
itemPowderIngot = ItemPowderIngot.create();
if (!hasGT5) {
itemPowderIngot = ItemPowderIngot.create();
}
registerFluids();
@@ -726,7 +729,9 @@ public class EnderIO {
SkeletonHandler.registerSkeleton(this);
}
MaterialRecipes.registerDependantOresInDictionary();
if (!hasGT5) {
MaterialRecipes.registerDependantOresInDictionary();
}
EnderfaceRecipes.addRecipes();
MaterialRecipes.addRecipes();
@@ -160,7 +160,6 @@ public class BlockConduitBundle extends BlockEio
BlockConduitBundle result = new BlockConduitBundle();
result.init();
MinecraftForge.EVENT_BUS.register(result);
return result;
}
@@ -292,41 +291,6 @@ public class BlockConduitBundle extends BlockEio
effectRenderer.addEffect(digFX);
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlaySound(PlaySoundSourceEvent event) {
String path = event.sound.getPositionedSoundLocation().getResourcePath();
if ("silence.step".equals(path)) {
ISound snd = event.sound;
World world = EnderIO.proxy.getClientWorld();
BlockCoord bc = new BlockCoord(snd.getXPosF(), snd.getYPosF(), snd.getZPosF());
TileEntity te = bc.getTileEntity(world);
if (te instanceof TileConduitBundle && ((TileConduitBundle) te).hasFacade()) {
Block facade = getFacade(world, bc.x, bc.y, bc.z, -1);
ConduitUtil.playHitSound(facade.stepSound, world, bc.x, bc.y, bc.z);
} else {
ConduitUtil.playHitSound(Block.soundTypeMetal, world, bc.x, bc.y, bc.z);
}
}
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlaySoundAtEntity(PlaySoundAtEntityEvent event) {
String path = event.name;
World world = event.entity.worldObj;
if ("EnderIO:silence.step".equals(path) && world.isRemote) {
BlockCoord bc = new BlockCoord(event.entity.posX, event.entity.posY - 2, event.entity.posZ);
TileEntity te = bc.getTileEntity(world);
if (te instanceof TileConduitBundle && ((TileConduitBundle) te).hasFacade()) {
Block facade = getFacade(world, bc.x, bc.y, bc.z, -1);
ConduitUtil.playStepSound(facade.stepSound, world, bc.x, bc.y, bc.z);
} else {
ConduitUtil.playStepSound(Block.soundTypeMetal, world, bc.x, bc.y, bc.z);
}
}
}
@Override
protected void init() {
super.init();
@@ -334,6 +298,7 @@ public class BlockConduitBundle extends BlockEio
EnderIO.guiHandler.registerGuiHandler(GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE + dir.ordinal(), this);
}
EnderIO.guiHandler.registerGuiHandler(GuiHandler.GUI_ID_EXTERNAL_CONNECTION_SELECTOR, this);
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
@@ -473,24 +438,6 @@ public class BlockConduitBundle extends BlockEio
: resist;
}
@SubscribeEvent
public void onBreakSpeed(BreakSpeed event) {
if (event.block == this) {
ItemStack held = event.entityPlayer.getCurrentEquippedItem();
if (held == null || held.getItem().getHarvestLevel(held, "pickaxe") == -1) {
event.newSpeed += 2;
}
IConduitBundle te = (IConduitBundle) event.entity.worldObj.getTileEntity(event.x, event.y, event.z);
if (te != null && te.getFacadeType() == FacadeType.HARDENED) {
if (!ConduitUtil.isSolidFacadeRendered(te, event.entityPlayer)) {
event.newSpeed *= 6;
} else {
event.newSpeed *= 2;
}
}
}
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
@@ -1274,4 +1221,61 @@ public class BlockConduitBundle extends BlockEio
private boolean hasMicroblocks(IConduitBundle bundle) {
return !bundle.getCoverSystem().getAllParts().isEmpty();
}
public class EventHandler {
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlaySound(PlaySoundSourceEvent event) {
String path = event.sound.getPositionedSoundLocation().getResourcePath();
if ("silence.step".equals(path)) {
ISound snd = event.sound;
World world = EnderIO.proxy.getClientWorld();
if (world == null) return;
BlockCoord bc = new BlockCoord(snd.getXPosF(), snd.getYPosF(), snd.getZPosF());
TileEntity te = bc.getTileEntity(world);
if (te instanceof TileConduitBundle && ((TileConduitBundle) te).hasFacade()) {
Block facade = getFacade(world, bc.x, bc.y, bc.z, -1);
ConduitUtil.playHitSound(facade.stepSound, world, bc.x, bc.y, bc.z);
} else {
ConduitUtil.playHitSound(Block.soundTypeMetal, world, bc.x, bc.y, bc.z);
}
}
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlaySoundAtEntity(PlaySoundAtEntityEvent event) {
String path = event.name;
World world = event.entity.worldObj;
if ("EnderIO:silence.step".equals(path) && world.isRemote) {
BlockCoord bc = new BlockCoord(event.entity.posX, event.entity.posY - 2, event.entity.posZ);
TileEntity te = bc.getTileEntity(world);
if (te instanceof TileConduitBundle && ((TileConduitBundle) te).hasFacade()) {
Block facade = getFacade(world, bc.x, bc.y, bc.z, -1);
ConduitUtil.playStepSound(facade.stepSound, world, bc.x, bc.y, bc.z);
} else {
ConduitUtil.playStepSound(Block.soundTypeMetal, world, bc.x, bc.y, bc.z);
}
}
}
@SubscribeEvent
public void onBreakSpeed(BreakSpeed event) {
if (event.block == BlockConduitBundle.this) {
ItemStack held = event.entityPlayer.getCurrentEquippedItem();
if (held == null || held.getItem().getHarvestLevel(held, "pickaxe") == -1) {
event.newSpeed += 2;
}
IConduitBundle te = (IConduitBundle) event.entity.worldObj.getTileEntity(event.x, event.y, event.z);
if (te != null && te.getFacadeType() == FacadeType.HARDENED) {
if (!ConduitUtil.isSolidFacadeRendered(te, event.entityPlayer)) {
event.newSpeed *= 6;
} else {
event.newSpeed *= 2;
}
}
}
}
}
}
@@ -10,7 +10,6 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -41,8 +40,8 @@ public class NetworkedInventory {
int tickDeficit;
// work around for a vanilla chest changing into a double chest without doing unneeded checks all the time
boolean recheckInv = false;
private TileEntity connectedTileEntity;
// Hack for TiC crafting station not working correctly when setting output slot to null
boolean ticHack = false;
@@ -61,19 +60,13 @@ public class NetworkedInventory {
this.location = location;
world = con.getBundle().getWorld();
TileEntity te = world.getTileEntity(location.x, location.y, location.z);
if (te.getClass().getName().equals("tconstruct.tools.logic.CraftingStationLogic")) {
ticHack = true;
} else if (te.getClass().getName().contains("cpw.mods.ironchest")) {
recheckInv = true;
} else if (te instanceof TileEntityChest) {
recheckInv = true;
} else if (te instanceof TileInventoryPanel) {
inventoryPanel = true;
}
updateInventory();
}
public boolean isInvalid() {
return connectedTileEntity == null || connectedTileEntity.isInvalid();
}
public boolean hasTarget(IItemConduit conduit, ForgeDirection dir) {
for (Target t : sendPriority) {
if (t.inv.con == conduit && t.inv.conDir == dir) {
@@ -110,6 +103,13 @@ public class NetworkedInventory {
}
public void onTick() {
if (isInvalid()) {
updateInventory();
if (isInvalid()) {
return;
}
}
if (tickDeficit > 0 || !canExtract() || !con.isExtractionRedstoneConditionMet(conDir)) {
// do nothing
} else {
@@ -144,11 +144,6 @@ public class NetworkedInventory {
}
private boolean transferItems() {
if (recheckInv) {
updateInventory();
}
int[] slotIndices = getInventory().getAccessibleSlotsFromSide(inventorySide);
if (slotIndices == null) {
return false;
@@ -257,9 +252,6 @@ public class NetworkedInventory {
matchedStickyInput = of != null && of.isValid() && of.doesItemPassFilter(this, toExtract);
}
if (target.stickyInput || !matchedStickyInput) {
if (target.inv.recheckInv) {
target.inv.updateInventory();
}
int inserted = target.inv.insertItem(toExtract);
if (inserted > 0) {
toExtract.stackSize -= inserted;
@@ -281,15 +273,38 @@ public class NetworkedInventory {
}
public final void updateInventory() {
TileEntity te = world.getTileEntity(location.x, location.y, location.z);
if (te instanceof ISidedInventory) {
inv = (ISidedInventory) te;
} else if (te instanceof IInventory) {
inv = new InventoryWrapper((IInventory) te);
TileEntity newTe = world.getTileEntity(location.x, location.y, location.z);
if (newTe != connectedTileEntity) {
connectedTileEntity = newTe;
ticHack = false;
inventoryPanel = false;
if (connectedTileEntity != null) {
if (connectedTileEntity.getClass().getName().equals("tconstruct.tools.logic.CraftingStationLogic")) {
ticHack = true;
} else if (connectedTileEntity instanceof TileInventoryPanel) {
inventoryPanel = true;
}
}
network.routesChanged();
}
if (connectedTileEntity instanceof ISidedInventory) {
inv = (ISidedInventory) connectedTileEntity;
} else if (connectedTileEntity instanceof IInventory) {
inv = new InventoryWrapper((IInventory) connectedTileEntity);
} else {
inv = null;
}
}
private int insertItem(ItemStack item) {
if (isInvalid()) {
updateInventory();
if (isInvalid()) {
return 0;
}
}
if (!canInsert() || item == null) {
return 0;
}
@@ -410,7 +425,7 @@ public class NetworkedInventory {
}
public ISidedInventory getInventoryRecheck() {
if (recheckInv) {
if (isInvalid()) {
updateInventory();
}
return inv;
@@ -11,12 +11,14 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import com.enderio.core.common.util.ChatUtil;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;
import cpw.mods.fml.common.gameevent.InputEvent.MouseInputEvent;
import crazypants.enderio.EnderIO;
import crazypants.enderio.api.teleport.IItemOfTravel;
import crazypants.enderio.api.tool.IConduitControl;
@@ -134,6 +136,18 @@ public class KeyTracker {
@SubscribeEvent
public void onKeyInput(KeyInputEvent event) {
handleInput();
}
// mouse button presses arrive on a separate event
@SubscribeEvent
public void onMouseInput(MouseInputEvent event) {
if (Mouse.getEventButton() >= 0) {
handleInput();
}
}
private void handleInput() {
handleGlide();
handleSoundDetector();
handleNightVision();
@@ -67,7 +67,6 @@ public class ItemDarkSteelAxe extends ItemAxe
public static ItemDarkSteelAxe create() {
ItemDarkSteelAxe res = new ItemDarkSteelAxe();
MinecraftForge.EVENT_BUS.register(res);
res.init();
return res;
}
@@ -188,18 +187,6 @@ public class ItemDarkSteelAxe extends ItemAxe
return usedPower;
}
@SubscribeEvent
public void onBreakSpeedEvent(PlayerEvent.BreakSpeed evt) {
if (evt.entityPlayer.isSneaking()
&& isEquippedAndPowered(evt.entityPlayer, Config.darkSteelAxePowerUsePerDamagePointMultiHarvest)
&& isLog(evt.block, evt.metadata)) {
evt.newSpeed = evt.originalSpeed / Config.darkSteelAxeSpeedPenaltyMultiHarvest;
}
if (isEquipped(evt.entityPlayer) && evt.block.getMaterial() == Material.leaves) {
evt.newSpeed = 6;
}
}
@Override
public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side,
float par8, float par9, float par10) {
@@ -258,6 +245,7 @@ public class ItemDarkSteelAxe extends ItemAxe
protected void init() {
GameRegistry.registerItem(this, getUnlocalizedName());
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
@@ -336,4 +324,19 @@ public class ItemDarkSteelAxe extends ItemAxe
return (x < y) ? -1 : ((x == y) ? 0 : 1);
}
}
public class EventHandler {
@SubscribeEvent
public void onBreakSpeedEvent(PlayerEvent.BreakSpeed evt) {
if (evt.entityPlayer.isSneaking()
&& isEquippedAndPowered(evt.entityPlayer, Config.darkSteelAxePowerUsePerDamagePointMultiHarvest)
&& isLog(evt.block, evt.metadata)) {
evt.newSpeed = evt.originalSpeed / Config.darkSteelAxeSpeedPenaltyMultiHarvest;
}
if (isEquipped(evt.entityPlayer) && evt.block.getMaterial() == Material.leaves) {
evt.newSpeed = 6;
}
}
}
}
@@ -16,7 +16,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import com.enderio.core.api.client.gui.IAdvancedTooltipProvider;
import com.enderio.core.common.util.ItemUtil;
@@ -61,7 +60,6 @@ public class ItemDarkSteelPickaxe extends ItemPickaxe
public static ItemDarkSteelPickaxe create() {
ItemDarkSteelPickaxe res = new ItemDarkSteelPickaxe();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -62,13 +62,12 @@ public class ItemDarkSteelShears extends ItemShears
public static ItemDarkSteelShears create() {
ItemDarkSteelShears res = new ItemDarkSteelShears();
MinecraftForge.EVENT_BUS.register(res);
res.init();
return res;
}
protected final MultiHarvestComparator harvestComparator = new MultiHarvestComparator();
protected final EntityComparator entityComparator = new EntityComparator();
private final MultiHarvestComparator harvestComparator = new MultiHarvestComparator();
private final EntityComparator entityComparator = new EntityComparator();
protected String name;
protected ItemDarkSteelShears(String name) {
@@ -202,14 +201,6 @@ public class ItemDarkSteelShears extends ItemShears
return false;
}
@SubscribeEvent
public void onBreakSpeedEvent(PlayerEvent.BreakSpeed evt) {
if (evt.originalSpeed > 2.0
&& isEquippedAndPowered(evt.entityPlayer, Config.darkSteelShearsPowerUsePerDamagePoint)) {
evt.newSpeed = evt.originalSpeed * Config.darkSteelShearsEffeciencyBoostWhenPowered;
}
}
@Override
public void setDamage(ItemStack stack, int newDamage) {
int oldDamage = getDamage(stack);
@@ -231,6 +222,7 @@ public class ItemDarkSteelShears extends ItemShears
protected void init() {
GameRegistry.registerItem(this, getUnlocalizedName());
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
@@ -330,4 +322,15 @@ public class ItemDarkSteelShears extends ItemShears
return 0;
}
}
public static class EventHandler {
@SubscribeEvent
public void onBreakSpeedEvent(PlayerEvent.BreakSpeed evt) {
if (evt.originalSpeed > 2.0
&& isEquippedAndPowered(evt.entityPlayer, Config.darkSteelShearsPowerUsePerDamagePoint)) {
evt.newSpeed = evt.originalSpeed * Config.darkSteelShearsEffeciencyBoostWhenPowered;
}
}
}
}
@@ -72,7 +72,6 @@ public class ItemDarkSteelSword extends ItemSword
public static ItemDarkSteelSword create() {
ItemDarkSteelSword res = new ItemDarkSteelSword();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -117,71 +116,6 @@ public class ItemDarkSteelSword extends ItemSword
return false;
}
@SubscribeEvent
public void onEnderTeleport(EnderTeleportEvent evt) {
if (evt.entityLiving.getEntityData().getBoolean("hitByDarkSteelSword")) {
evt.setCanceled(true);
}
}
// Set priorty to lowest in the hope any other mod adding head drops will have already added them
// by the time this is called to prevent multiple head drops
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onEntityDrop(LivingDropsEvent evt) {
if (!(evt.source.getEntity() instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) evt.source.getEntity();
// Handle TiC weapons with beheading differently
if (handleBeheadingWeapons(player, evt)) {
return;
}
double skullDropChance = getSkullDropChance(player, evt);
if (player instanceof FakePlayer) {
skullDropChance *= Config.fakePlayerSkullChance;
}
if (Math.random() <= skullDropChance) {
dropSkull(evt, player);
}
// Special handling for ender pear drops
if (isEquipped(player)) {
String name = EntityList.getEntityString(evt.entityLiving);
if (evt.entityLiving instanceof EntityEnderman || ENDERZOO_ENDERMINY.equals(name)) {
int numPearls = 0;
if (Math.random() <= Config.darkSteelSwordEnderPearlDropChance) {
numPearls++;
}
for (int i = 0; i < evt.lootingLevel; i++) {
if (Math.random() <= Config.darkSteelSwordEnderPearlDropChancePerLooting) {
numPearls++;
}
}
int existing = 0;
for (EntityItem stack : evt.drops) {
if (stack.getEntityItem() != null && stack.getEntityItem().getItem() == Items.ender_pearl) {
existing += stack.getEntityItem().stackSize;
}
}
int toDrop = numPearls - existing;
if (toDrop > 0) {
evt.drops.add(
Util.createDrop(
player.worldObj,
new ItemStack(Items.ender_pearl, toDrop, 0),
evt.entityLiving.posX,
evt.entityLiving.posY,
evt.entityLiving.posZ,
false));
}
}
}
}
protected void dropSkull(LivingDropsEvent evt, EntityPlayer player) {
ItemStack skull = getSkullForEntity(evt.entityLiving);
if (skull != null && !containsDrop(evt, skull)) {
@@ -292,6 +226,7 @@ public class ItemDarkSteelSword extends ItemSword
protected void init() {
GameRegistry.registerItem(this, getUnlocalizedName());
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
@@ -437,4 +372,73 @@ public class ItemDarkSteelSword extends ItemSword
return super.onItemRightClick(stack, world, player);
}
public class EventHandler {
@SubscribeEvent
public void onEnderTeleport(EnderTeleportEvent evt) {
if (evt.entityLiving.getEntityData().getBoolean("hitByDarkSteelSword")) {
evt.setCanceled(true);
}
}
// Set priorty to lowest in the hope any other mod adding head drops will have already added them
// by the time this is called to prevent multiple head drops
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onEntityDrop(LivingDropsEvent evt) {
if (!(evt.source.getEntity() instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) evt.source.getEntity();
// Handle TiC weapons with beheading differently
if (handleBeheadingWeapons(player, evt)) {
return;
}
double skullDropChance = getSkullDropChance(player, evt);
if (player instanceof FakePlayer) {
skullDropChance *= Config.fakePlayerSkullChance;
}
if (Math.random() <= skullDropChance) {
dropSkull(evt, player);
}
// Special handling for ender pear drops
if (isEquipped(player)) {
String name = EntityList.getEntityString(evt.entityLiving);
if (evt.entityLiving instanceof EntityEnderman || ENDERZOO_ENDERMINY.equals(name)) {
int numPearls = 0;
if (Math.random() <= Config.darkSteelSwordEnderPearlDropChance) {
numPearls++;
}
for (int i = 0; i < evt.lootingLevel; i++) {
if (Math.random() <= Config.darkSteelSwordEnderPearlDropChancePerLooting) {
numPearls++;
}
}
int existing = 0;
for (EntityItem stack : evt.drops) {
if (stack.getEntityItem() != null && stack.getEntityItem().getItem() == Items.ender_pearl) {
existing += stack.getEntityItem().stackSize;
}
}
int toDrop = numPearls - existing;
if (toDrop > 0) {
evt.drops.add(
Util.createDrop(
player.worldObj,
new ItemStack(Items.ender_pearl, toDrop, 0),
evt.entityLiving.posX,
evt.entityLiving.posY,
evt.entityLiving.posZ,
false));
}
}
}
}
}
}
@@ -6,7 +6,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -30,7 +29,6 @@ public class ItemEndSteelAxe extends ItemDarkSteelAxe implements IEndSteelItem {
public static ItemEndSteelAxe create() {
ItemEndSteelAxe res = new ItemEndSteelAxe();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -6,7 +6,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -30,7 +29,6 @@ public class ItemEndSteelPickaxe extends ItemDarkSteelPickaxe implements IEndSte
public static ItemEndSteelPickaxe create() {
ItemEndSteelPickaxe res = new ItemEndSteelPickaxe();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -6,7 +6,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import cpw.mods.fml.relauncher.Side;
@@ -35,7 +34,6 @@ public class ItemEndSteelSword extends ItemDarkSteelSword implements IEndSteelIt
public static ItemEndSteelSword create() {
ItemEndSteelSword res = new ItemEndSteelSword();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -6,7 +6,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -30,7 +29,6 @@ public class ItemStellarAxe extends ItemDarkSteelAxe implements IStellarItem {
public static ItemStellarAxe create() {
ItemStellarAxe res = new ItemStellarAxe();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -6,7 +6,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -30,7 +29,6 @@ public class ItemStellarPickaxe extends ItemDarkSteelPickaxe implements IStellar
public static ItemStellarPickaxe create() {
ItemStellarPickaxe res = new ItemStellarPickaxe();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -6,7 +6,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import cpw.mods.fml.relauncher.Side;
@@ -35,7 +34,6 @@ public class ItemStellarSword extends ItemDarkSteelSword implements IStellarItem
public static ItemStellarSword create() {
ItemStellarSword res = new ItemStellarSword();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -89,7 +89,9 @@ public class ContainerCapBank extends ContainerEnderTileEntity<TileCapBank> {
}
if (hasBaublesSlots()) {
for (int i = 0; i < baubles.getSizeInventory(); i++) {
// for (int i = 0; i < baubles.getSizeInventory(); i++) {
// Capped since the sprite only has 4 slots
for (int i = 0; i < Math.min(baubles.getSizeInventory(), 4); i++) {
addSlotToContainer(new Slot(baubles, i, -15 + armorOffset, 84 + i * 18) {
@Override
@@ -122,7 +124,9 @@ public class ContainerCapBank extends ContainerEnderTileEntity<TileCapBank> {
int startHotBarSlot = endPlayerSlot + 1;
int endHotBarSlot = startHotBarSlot + 9;
int startBaublesSlot = endHotBarSlot + 1;
int endBaublesSlot = baubles == null ? 0 : startBaublesSlot + baubles.getSizeInventory();
// int endBaublesSlot = baubles == null ? 0 : startBaublesSlot + baubles.getSizeInventory();
// Capped since the sprite only has 4 slots
int endBaublesSlot = baubles == null ? 0 : startBaublesSlot + Math.min(baubles.getSizeInventory(), 4);
ItemStack copystack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
@@ -17,7 +17,9 @@ import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import com.enderio.core.common.util.BlockCoord;
import com.mitchej123.hodgepodge.mixins.interfaces.INetherSeed;
import crazypants.enderio.EnderIO;
import crazypants.enderio.machine.farm.TileFarmStation;
public class PlantableFarmer implements IFarmerJoe {
@@ -109,7 +111,13 @@ public class PlantableFarmer implements IFarmerJoe {
protected boolean plant(TileFarmStation farm, World worldObj, BlockCoord bc, IPlantable plantable) {
worldObj.setBlock(bc.x, bc.y, bc.z, Blocks.air, 0, 1 | 2);
Block target = plantable.getPlant(null, 0, 0, 0);
Block target;
// needed for Pam's nether seeds
if (EnderIO.hasHP && plantable instanceof INetherSeed netherSeed) {
target = netherSeed.hodgepodge$getPlant(null, 0, 0, 0);
} else {
target = plantable.getPlant(null, 0, 0, 0);
}
int meta = plantable.getPlantMetadata(null, 0, 0, 0);
worldObj.setBlock(bc.x, bc.y, bc.z, target, meta, 1 | 2);
farm.actionPerformed(false);
@@ -117,7 +125,13 @@ public class PlantableFarmer implements IFarmerJoe {
}
protected boolean canPlant(World worldObj, BlockCoord bc, IPlantable plantable) {
Block target = plantable.getPlant(null, 0, 0, 0);
Block target;
// needed for Pam's nether seeds
if (EnderIO.hasHP && plantable instanceof INetherSeed netherSeed) {
target = netherSeed.hodgepodge$getPlant(null, 0, 0, 0);
} else {
target = plantable.getPlant(null, 0, 0, 0);
}
Block ground = worldObj.getBlock(bc.x, bc.y - 1, bc.z);
if (target != null && target.canPlaceBlockAt(worldObj, bc.x, bc.y, bc.z)
&& target.canBlockStay(worldObj, bc.x, bc.y, bc.z)
@@ -182,10 +196,14 @@ public class PlantableFarmer implements IFarmerJoe {
}
private boolean isPlantableForBlock(ItemStack stack, Block block) {
if (!(stack.getItem() instanceof IPlantable)) {
return false;
if (stack.getItem() instanceof IPlantable plantable) {
// needed for Pam's nether seeds
if (EnderIO.hasHP && plantable instanceof INetherSeed netherSeed) {
return netherSeed.hodgepodge$getPlant(null, 0, 0, 0) == block;
} else {
return plantable.getPlant(null, 0, 0, 0) == block;
}
}
IPlantable plantable = (IPlantable) stack.getItem();
return plantable.getPlant(null, 0, 0, 0) == block;
return false;
}
}
@@ -28,9 +28,7 @@ public class BlockKillerJoe extends AbstractMachineBlock<TileKillerJoe> {
.registerMessage(PacketSwing.class, PacketSwing.class, PacketHandler.nextID(), Side.CLIENT);
PacketGivePlayerXP.register();
PacketExperianceContainer.register();
BlockKillerJoe res = new BlockKillerJoe();
MinecraftForge.EVENT_BUS.register(res);
res.init();
return res;
}
@@ -40,19 +38,18 @@ public class BlockKillerJoe extends AbstractMachineBlock<TileKillerJoe> {
setStepSound(Block.soundTypeGlass);
}
@Override
protected void init() {
super.init();
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX,
double explosionY, double explosionZ) {
return 2000;
}
@SubscribeEvent
public void getKillDisplayName(PlayerEvent.NameFormat nameEvt) {
if (nameEvt.username != null && nameEvt.username.startsWith(USERNAME)) {
nameEvt.displayname = getLocalizedName();
}
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new ContainerKillerJoe(player.inventory, (TileKillerJoe) world.getTileEntity(x, y, z));
@@ -101,4 +98,14 @@ public class BlockKillerJoe extends AbstractMachineBlock<TileKillerJoe> {
return 5;
}
}
public class EventHandler {
@SubscribeEvent
public void getKillDisplayName(PlayerEvent.NameFormat nameEvt) {
if (nameEvt.username != null && nameEvt.username.startsWith(USERNAME)) {
nameEvt.displayname = getLocalizedName();
}
}
}
}
@@ -25,7 +25,6 @@ public class BlockInhibitorObelisk extends BlockObeliskAbstract<TileInhibitorObe
public static BlockInhibitorObelisk create() {
BlockInhibitorObelisk res = new BlockInhibitorObelisk();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return instance = res;
}
@@ -33,6 +32,12 @@ public class BlockInhibitorObelisk extends BlockObeliskAbstract<TileInhibitorObe
super(ModObject.blockInhibitorObelisk, TileInhibitorObelisk.class);
}
@Override
protected void init() {
super.init();
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return ID == getGuiId()
@@ -58,15 +63,18 @@ public class BlockInhibitorObelisk extends BlockObeliskAbstract<TileInhibitorObe
public Map<BlockCoord, Float> activeInhibitors = Maps.newHashMap();
@SubscribeEvent
public void onTeleport(TeleportEntityEvent event) {
for (Entry<BlockCoord, Float> e : activeInhibitors.entrySet()) {
BlockCoord bc = e.getKey();
int dist = bc.getDist(new BlockCoord(event.targetX, event.targetY, event.targetZ));
if (dist < e.getValue()) {
TileEntity te = bc.getTileEntity(event.entity.worldObj);
if (te instanceof TileInhibitorObelisk && ((TileInhibitorObelisk) te).isActive()) {
event.setCanceled(true);
public class EventHandler {
@SubscribeEvent
public void onTeleport(TeleportEntityEvent event) {
for (Entry<BlockCoord, Float> e : activeInhibitors.entrySet()) {
BlockCoord bc = e.getKey();
int dist = bc.getDist(new BlockCoord(event.targetX, event.targetY, event.targetZ));
if (dist < e.getValue()) {
TileEntity te = bc.getTileEntity(event.entity.worldObj);
if (te instanceof TileInhibitorObelisk && ((TileInhibitorObelisk) te).isActive()) {
event.setCanceled(true);
}
}
}
}
@@ -199,7 +199,7 @@ public class BlockPaintedGlowstone extends BlockEio
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister IIconRegister) {
blockIcon = IIconRegister.registerIcon("enderio:conduitConnector");
blockIcon = IIconRegister.registerIcon("glowstone");
}
@Override
@@ -231,10 +231,12 @@ public class BlockPaintedGlowstone extends BlockEio
@Override
protected void processDrop(World world, int x, int y, int z, TileEntityEnder te, ItemStack drop) {
TileEntityPaintedBlock tef = (TileEntityPaintedBlock) te;
if (tef != null) {
if (te instanceof TileEntityPaintedBlock tef) {
ItemStack itemStack = createItemStackForSourceBlock(tef.getSourceBlock(), tef.getSourceBlockMetadata());
drop.stackTagCompound = (NBTTagCompound) itemStack.stackTagCompound.copy();
NBTTagCompound tag = itemStack.stackTagCompound;
if (tag != null) {
drop.stackTagCompound = (NBTTagCompound) tag.copy();
}
}
}
@@ -63,7 +63,8 @@ public final class PainterUtil {
sourceName = is.getDisplayName();
}
}
return EnderIO.lang.localize("blockPainter.paintedWith") + " " + sourceName;
return EnderIO.lang.localize("blockPainter.paintedWith") + " "
+ (sourceName.isEmpty() ? EnderIO.lang.localize("blockPainter.paintedWith.none") : sourceName);
}
public static void setSourceBlock(ItemStack item, Block source, int meta) {
@@ -89,8 +89,6 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
PoweredSpawnerConfig.getInstance();
BlockPoweredSpawner res = new BlockPoweredSpawner();
MinecraftForge.EVENT_BUS.register(res);
FMLCommonHandler.instance().bus().register(res);
res.init();
return res;
}
@@ -115,144 +113,16 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
}
}
@Override
protected void init() {
super.init();
EventHandler handler = new EventHandler();
MinecraftForge.EVENT_BUS.register(handler);
FMLCommonHandler.instance().bus().register(handler);
}
private final Map<BlockCoord, ItemStack> dropCache = new HashMap<BlockCoord, ItemStack>();
@SubscribeEvent
public void onBreakEvent(BlockEvent.BreakEvent evt) {
if (evt.block instanceof BlockMobSpawner) {
if (evt.getPlayer() != null && !evt.getPlayer().capabilities.isCreativeMode
&& !evt.getPlayer().worldObj.isRemote
&& !evt.isCanceled()) {
TileEntity tile = evt.getPlayer().worldObj.getTileEntity(evt.x, evt.y, evt.z);
if (tile instanceof TileEntityMobSpawner) {
if (Math.random() > Config.brokenSpawnerDropChance) {
return;
}
ItemStack equipped = evt.getPlayer().getCurrentEquippedItem();
if (equipped != null) {
for (UniqueIdentifier uid : toolBlackList) {
Item blackListItem = GameRegistry.findItem(uid.modId, uid.name);
if (blackListItem == equipped.getItem()) {
return;
}
}
}
TileEntityMobSpawner spawner = (TileEntityMobSpawner) tile;
MobSpawnerBaseLogic logic = spawner.func_145881_a();
if (logic != null) {
String name = logic.getEntityNameToSpawn();
if (name != null && !isBlackListed(name)) {
ItemStack drop = ItemBrokenSpawner.createStackForMobType(name);
dropCache.put(new BlockCoord(evt.x, evt.y, evt.z), drop);
for (int i = (int) (Math.random() * 7); i > 0; i--) {
logic.spawnDelay = 0;
logic.updateSpawner();
}
}
}
}
} else {
dropCache.put(new BlockCoord(evt.x, evt.y, evt.z), null);
}
}
}
@SubscribeEvent
public void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent evt) {
if (!evt.isCanceled() && evt.block instanceof BlockMobSpawner) {
BlockCoord bc = new BlockCoord(evt.x, evt.y, evt.z);
if (dropCache.containsKey(bc)) {
ItemStack stack = dropCache.get(bc);
if (stack != null) {
evt.drops.add(stack);
}
} else {
// A spawner was broken---but not by a player. The TE has been
// invalidated already, but we might be able to recover it.
try {
for (Object object : evt.world.loadedTileEntityList) {
if (object instanceof TileEntityMobSpawner) {
TileEntityMobSpawner spawner = (TileEntityMobSpawner) object;
if (spawner.getWorldObj() == evt.world && spawner.xCoord == evt.x
&& spawner.yCoord == evt.y
&& spawner.zCoord == evt.z) {
// Bingo!
MobSpawnerBaseLogic logic = spawner.func_145881_a();
if (logic != null) {
String name = logic.getEntityNameToSpawn();
if (name != null && !isBlackListed(name)) {
evt.drops.add(ItemBrokenSpawner.createStackForMobType(name));
}
}
}
}
}
} catch (Exception e) {
// Risky recovery failed. Happens.
}
}
}
}
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
dropCache.clear();
}
}
@SubscribeEvent
public void handleAnvilEvent(AnvilUpdateEvent evt) {
if (evt.left == null || evt.left.stackSize != 1
|| evt.left.getItem() != Item.getItemFromBlock(EnderIO.blockPoweredSpawner)
|| evt.right == null
|| ItemBrokenSpawner.getMobTypeFromStack(evt.right) == null) {
return;
}
String spawnerType = ItemBrokenSpawner.getMobTypeFromStack(evt.right);
if (isBlackListed(spawnerType)) {
return;
}
evt.cost = Config.powerSpawnerAddSpawnerCost;
evt.output = evt.left.copy();
if (evt.output.stackTagCompound == null) {
evt.output.stackTagCompound = new NBTTagCompound();
}
evt.output.stackTagCompound.setBoolean("eio.abstractMachine", true);
writeMobTypeToNBT(evt.output.stackTagCompound, spawnerType);
}
@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent livingUpdate) {
Entity ent = livingUpdate.entityLiving;
if (!ent.getEntityData().hasKey(KEY_SPAWNED_BY_POWERED_SPAWNER)) {
return;
}
if (fieldpersistenceRequired == null) {
ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER);
return;
}
long spawnTime = ent.getEntityData().getLong(KEY_SPAWNED_BY_POWERED_SPAWNER);
long livedFor = livingUpdate.entity.worldObj.getTotalWorldTime() - spawnTime;
if (livedFor > Config.poweredSpawnerDespawnTimeSeconds * 20) {
try {
fieldpersistenceRequired.setBoolean(livingUpdate.entityLiving, false);
ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER);
} catch (Exception e) {
Log.warn("BlockPoweredSpawner.onLivingUpdate: Error occured allowing entity to despawn: " + e);
ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER);
}
}
}
public boolean isBlackListed(String entityId) {
return PoweredSpawnerConfig.getInstance().isBlackListed(entityId);
}
@@ -362,4 +232,144 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
Util.dropItems(evt.getPlayer().worldObj, drop, evt.x, evt.y, evt.z, true);
}
}
public class EventHandler {
@SubscribeEvent
public void onBreakEvent(BlockEvent.BreakEvent evt) {
if (evt.block instanceof BlockMobSpawner) {
if (evt.getPlayer() != null && !evt.getPlayer().capabilities.isCreativeMode
&& !evt.getPlayer().worldObj.isRemote
&& !evt.isCanceled()) {
TileEntity tile = evt.getPlayer().worldObj.getTileEntity(evt.x, evt.y, evt.z);
if (tile instanceof TileEntityMobSpawner) {
if (Math.random() > Config.brokenSpawnerDropChance) {
return;
}
ItemStack equipped = evt.getPlayer().getCurrentEquippedItem();
if (equipped != null) {
for (UniqueIdentifier uid : toolBlackList) {
Item blackListItem = GameRegistry.findItem(uid.modId, uid.name);
if (blackListItem == equipped.getItem()) {
return;
}
}
}
TileEntityMobSpawner spawner = (TileEntityMobSpawner) tile;
MobSpawnerBaseLogic logic = spawner.func_145881_a();
if (logic != null) {
String name = logic.getEntityNameToSpawn();
if (name != null && !isBlackListed(name)) {
ItemStack drop = ItemBrokenSpawner.createStackForMobType(name);
dropCache.put(new BlockCoord(evt.x, evt.y, evt.z), drop);
for (int i = (int) (Math.random() * 7); i > 0; i--) {
logic.spawnDelay = 0;
logic.updateSpawner();
}
}
}
}
} else {
dropCache.put(new BlockCoord(evt.x, evt.y, evt.z), null);
}
}
}
@SubscribeEvent
public void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent evt) {
if (!evt.isCanceled() && evt.block instanceof BlockMobSpawner) {
BlockCoord bc = new BlockCoord(evt.x, evt.y, evt.z);
if (dropCache.containsKey(bc)) {
ItemStack stack = dropCache.get(bc);
if (stack != null) {
evt.drops.add(stack);
}
} else {
// A spawner was broken---but not by a player. The TE has been
// invalidated already, but we might be able to recover it.
try {
for (Object object : evt.world.loadedTileEntityList) {
if (object instanceof TileEntityMobSpawner) {
TileEntityMobSpawner spawner = (TileEntityMobSpawner) object;
if (spawner.getWorldObj() == evt.world && spawner.xCoord == evt.x
&& spawner.yCoord == evt.y
&& spawner.zCoord == evt.z) {
// Bingo!
MobSpawnerBaseLogic logic = spawner.func_145881_a();
if (logic != null) {
String name = logic.getEntityNameToSpawn();
if (name != null && !isBlackListed(name)) {
evt.drops.add(ItemBrokenSpawner.createStackForMobType(name));
}
}
}
}
}
} catch (Exception e) {
// Risky recovery failed. Happens.
}
}
}
}
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
dropCache.clear();
}
}
@SubscribeEvent
public void handleAnvilEvent(AnvilUpdateEvent evt) {
if (evt.left == null || evt.left.stackSize != 1
|| evt.left.getItem() != Item.getItemFromBlock(EnderIO.blockPoweredSpawner)
|| evt.right == null
|| ItemBrokenSpawner.getMobTypeFromStack(evt.right) == null) {
return;
}
String spawnerType = ItemBrokenSpawner.getMobTypeFromStack(evt.right);
if (isBlackListed(spawnerType)) {
return;
}
evt.cost = Config.powerSpawnerAddSpawnerCost;
evt.output = evt.left.copy();
if (evt.output.stackTagCompound == null) {
evt.output.stackTagCompound = new NBTTagCompound();
}
evt.output.stackTagCompound.setBoolean("eio.abstractMachine", true);
writeMobTypeToNBT(evt.output.stackTagCompound, spawnerType);
}
@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent livingUpdate) {
Entity ent = livingUpdate.entityLiving;
if (!ent.getEntityData().hasKey(KEY_SPAWNED_BY_POWERED_SPAWNER)) {
return;
}
if (fieldpersistenceRequired == null) {
ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER);
return;
}
long spawnTime = ent.getEntityData().getLong(KEY_SPAWNED_BY_POWERED_SPAWNER);
long livedFor = livingUpdate.entity.worldObj.getTotalWorldTime() - spawnTime;
if (livedFor > Config.poweredSpawnerDespawnTimeSeconds * 20) {
try {
fieldpersistenceRequired.setBoolean(livingUpdate.entityLiving, false);
ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER);
} catch (Exception e) {
Log.warn("BlockPoweredSpawner.onLivingUpdate: Error occured allowing entity to despawn: " + e);
ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER);
}
}
}
}
}
@@ -1,5 +1,6 @@
package crazypants.enderio.material;
import static crazypants.enderio.EnderIO.hasGT5;
import static crazypants.enderio.material.Alloy.DARK_STEEL;
import static crazypants.enderio.material.Alloy.END_STEEL;
import static crazypants.enderio.material.Alloy.ENERGETIC_ALLOY;
@@ -58,10 +59,13 @@ public class MaterialRecipes {
public static void registerOresInDictionary() {
// Ore Dictionary Registration
for (PowderIngot powder : PowderIngot.values()) {
if (!powder.hasDependancy()) {
OreDictionary
.registerOre(powder.oreDictName, new ItemStack(EnderIO.itemPowderIngot, 1, powder.ordinal()));
if (!hasGT5) {
for (PowderIngot powder : PowderIngot.values()) {
if (!powder.hasDependancy()) {
OreDictionary.registerOre(
powder.oreDictName,
new ItemStack(EnderIO.itemPowderIngot, 1, powder.ordinal()));
}
}
}
@@ -431,17 +435,19 @@ public class MaterialRecipes {
RecipeUtil.addShaped(vibCry, "nnn", "ngn", "nnn", 'n', vibrantNugget, 'g', "gemEmerald");
// Smelting
ItemStack dustIron = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_IRON.ordinal());
ItemStack dustGold = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_GOLD.ordinal());
ItemStack ingotIron = new ItemStack(Items.iron_ingot);
ItemStack ingotGold = new ItemStack(Items.gold_ingot);
if (!hasGT5) {
ItemStack dustIron = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_IRON.ordinal());
ItemStack dustGold = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_GOLD.ordinal());
ItemStack ingotIron = new ItemStack(Items.iron_ingot);
ItemStack ingotGold = new ItemStack(Items.gold_ingot);
GameRegistry.addSmelting(dustIron, ingotIron, 0);
GameRegistry.addSmelting(dustGold, ingotGold, 0);
GameRegistry.addSmelting(dustIron, ingotIron, 0);
GameRegistry.addSmelting(dustGold, ingotGold, 0);
// Ender Dusts
ItemStack enderDust = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_ENDER.ordinal());
RecipeUtil.addShaped(new ItemStack(Items.ender_pearl), "eee", "eee", "eee", 'e', enderDust);
// Ender Dusts
ItemStack enderDust = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_ENDER.ordinal());
RecipeUtil.addShaped(new ItemStack(Items.ender_pearl), "eee", "eee", "eee", 'e', enderDust);
}
// Dark Iron Bars
ItemStack diBars = new ItemStack(EnderIO.blockDarkIronBars, 16, 0);
@@ -564,24 +570,29 @@ public class MaterialRecipes {
ItemStack darkRod = new ItemStack(EnderIO.itemMaterial, 1, Material.DARK_STEEL_ROD.ordinal());
RecipeUtil.addShaped(darkRod, " ns", "nsn", "sn ", 's', darkSteel, 'n', endSteelNugget);
// Food
ItemStack flour = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.FLOUR.ordinal());
ItemStack bread = new ItemStack(Items.bread, 1, 0);
if (!hasGT5) {
// Food
ItemStack flour = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.FLOUR.ordinal());
ItemStack bread = new ItemStack(Items.bread, 1, 0);
GameRegistry.addSmelting(flour, bread, 0.35f);
GameRegistry.addSmelting(flour, bread, 0.35f);
}
ItemStack enderios = EnderFood.ENDERIOS.getStack();
RecipeUtil.addShapeless(enderios, Items.bowl, Items.milk_bucket, "cropWheat", "dustEnderPearl");
if (OreDictionaryHelper.hasCopper()) {
ItemStack dustCopper = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_COPPER.ordinal());
ItemStack ingotCoppper = OreDictionaryPreferences.instance.getPreferred(OreDictionaryHelper.INGOT_COPPER);
GameRegistry.addSmelting(dustCopper, ingotCoppper, 0);
}
if (OreDictionaryHelper.hasTin()) {
ItemStack dustTin = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_TIN.ordinal());
ItemStack ingotTin = OreDictionaryPreferences.instance.getPreferred(OreDictionaryHelper.INGOT_TIN);
GameRegistry.addSmelting(dustTin, ingotTin, 0);
if (!hasGT5) {
if (OreDictionaryHelper.hasCopper()) {
ItemStack dustCopper = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_COPPER.ordinal());
ItemStack ingotCoppper = OreDictionaryPreferences.instance
.getPreferred(OreDictionaryHelper.INGOT_COPPER);
GameRegistry.addSmelting(dustCopper, ingotCoppper, 0);
}
if (OreDictionaryHelper.hasTin()) {
ItemStack dustTin = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_TIN.ordinal());
ItemStack ingotTin = OreDictionaryPreferences.instance.getPreferred(OreDictionaryHelper.INGOT_TIN);
GameRegistry.addSmelting(dustTin, ingotTin, 0);
}
}
}
}
+40 -25
View File
@@ -1,5 +1,6 @@
package crazypants.util;
import static crazypants.enderio.EnderIO.hasGT5;
import static crazypants.enderio.material.Material.BINDER_COMPOSITE;
import static crazypants.enderio.material.Material.CONDUIT_BINDER;
import static crazypants.enderio.material.Material.PHASED_IRON_NUGGET;
@@ -9,6 +10,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@@ -20,6 +22,7 @@ import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy;
import com.pahimar.ee3.api.exchange.RecipeRegistryProxy;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import crazypants.enderio.EnderIO;
import crazypants.enderio.config.Config;
import crazypants.enderio.item.ItemEnderFood.EnderFood;
@@ -93,47 +96,59 @@ public class EE3Util {
*/
public static void registerMiscRecipes() {
if (IS_EE3_LOADED) {
ItemStack basicGear = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.BASIC_GEAR.ordinal());
ItemStack stick4 = new ItemStack(Items.stick, 4);
ItemStack cobble4 = new ItemStack(Blocks.cobblestone, 4);
registerRecipe(basicGear, stick4, cobble4);
ItemStack flour10 = new ItemStack(EnderIO.itemPowderIngot, 10, PowderIngot.FLOUR.ordinal());
ItemStack wheat5 = new ItemStack(Items.wheat, 5);
ItemStack seeds1 = new ItemStack(Items.wheat_seeds, 1);
registerRecipe(flour10, wheat5, seeds1);
if (!hasGT5) {
ItemStack basicGear = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.BASIC_GEAR.ordinal());
ItemStack stick4 = new ItemStack(Items.stick, 4);
ItemStack cobble4 = new ItemStack(Blocks.cobblestone, 4);
registerRecipe(basicGear, stick4, cobble4);
ItemStack flour10 = new ItemStack(EnderIO.itemPowderIngot, 10, PowderIngot.FLOUR.ordinal());
ItemStack wheat5 = new ItemStack(Items.wheat, 5);
ItemStack seeds1 = new ItemStack(Items.wheat_seeds, 1);
registerRecipe(flour10, wheat5, seeds1);
}
ItemStack enderios = EnderFood.ENDERIOS.getStack();
ItemStack bowl = new ItemStack(Items.bowl, 1);
ItemStack wheat = new ItemStack(Items.wheat, 1);
ItemStack milkb = new ItemStack(Items.milk_bucket, 1);
FluidStack milk = FluidContainerRegistry.getFluidForFilledItem(milkb);
ItemStack dustEnderPearl = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_ENDER.ordinal());
ItemStack dustEnderPearl;
if (hasGT5) {
dustEnderPearl = GameRegistry.findItemStack("gregtech", "gt.metaitem.01", 1);
Items.feather.setDamage(Objects.requireNonNull(dustEnderPearl), 2532);
} else {
dustEnderPearl = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_ENDER.ordinal());
}
if (milk != null) {
registerRecipe(enderios, bowl, milk, wheat, dustEnderPearl);
} else {
registerRecipe(enderios, bowl, milkb, wheat, dustEnderPearl);
}
ItemStack dustCoal = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_COAL.ordinal());
ItemStack coal = new ItemStack(Items.coal, 1);
registerRecipe(dustCoal, coal);
if (!hasGT5) {
ItemStack dustCoal = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_COAL.ordinal());
ItemStack coal = new ItemStack(Items.coal, 1);
registerRecipe(dustCoal, coal);
ItemStack dustIron = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_IRON.ordinal());
ItemStack iron = new ItemStack(Items.iron_ingot, 1);
registerRecipe(dustIron, iron);
ItemStack dustIron = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_IRON.ordinal());
ItemStack iron = new ItemStack(Items.iron_ingot, 1);
registerRecipe(dustIron, iron);
ItemStack dustGold = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_GOLD.ordinal());
ItemStack gold = new ItemStack(Items.gold_ingot, 1);
registerRecipe(dustGold, gold);
ItemStack dustGold = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_GOLD.ordinal());
ItemStack gold = new ItemStack(Items.gold_ingot, 1);
registerRecipe(dustGold, gold);
ItemStack dustObsidian4 = new ItemStack(EnderIO.itemPowderIngot, 4, PowderIngot.POWDER_OBSIDIAN.ordinal());
ItemStack obsidian = new ItemStack(Blocks.obsidian, 1);
registerRecipe(dustObsidian4, obsidian);
ItemStack dustObsidian4 = new ItemStack(
EnderIO.itemPowderIngot,
4,
PowderIngot.POWDER_OBSIDIAN.ordinal());
ItemStack obsidian = new ItemStack(Blocks.obsidian, 1);
registerRecipe(dustObsidian4, obsidian);
ItemStack enderDust9 = new ItemStack(EnderIO.itemPowderIngot, 9, PowderIngot.POWDER_ENDER.ordinal());
ItemStack enderPearl = new ItemStack(Items.ender_pearl);
registerRecipe(enderDust9, enderPearl);
ItemStack enderDust9 = new ItemStack(EnderIO.itemPowderIngot, 9, PowderIngot.POWDER_ENDER.ordinal());
ItemStack enderPearl = new ItemStack(Items.ender_pearl);
registerRecipe(enderDust9, enderPearl);
}
ItemStack cbc8 = BINDER_COMPOSITE.getStack(8);
ItemStack sand2 = new ItemStack(Blocks.sand, 2);
@@ -777,6 +777,7 @@ enderio.itemCoordSelector.chat.setDimension=Set Dimension: %s%s
#Painter
tile.blockPainter.name=Painting Machine
enderio.blockPainter.paintedWith=Painted with:
enderio.blockPainter.paintedWith.none=§onothing§r
tile.blockPaintedFence.name=Painted Fence
tile.blockPaintedFenceGate.name=Painted Gate
tile.blockPaintedWall.name=Painted Wall
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB