Skip to content

Commit

Permalink
misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss committed Sep 6, 2021
1 parent 3b90ff3 commit c3cdf2e
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 154 deletions.
1 change: 0 additions & 1 deletion src/main/java/gregtech/GregTechMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public class GregTechMod {
public void onPreInit(FMLPreInitializationEvent event) {
NetworkHandler.init();

MinecraftForge.EVENT_BUS.register(new EventHandlers());
GTLog.init(event.getModLog());
MetaTileEntityUIFactory.INSTANCE.init();
PlayerInventoryUIFactory.INSTANCE.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntityEndermite;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.potion.PotionEffect;
Expand Down Expand Up @@ -48,10 +49,9 @@ public int getMaxLevel() {
@Override
public void onEntityDamaged(@Nonnull EntityLivingBase hurtEntity, @Nonnull Entity damagingEntity, int level) {
String entityName = EntityList.getEntityString(hurtEntity);
if (hurtEntity instanceof EntityEnderman || hurtEntity instanceof EntityDragon || (entityName != null && entityName.toLowerCase().contains("ender"))) {
if (hurtEntity instanceof EntityEnderman || hurtEntity instanceof EntityDragon || hurtEntity instanceof EntityEndermite || (entityName != null && entityName.toLowerCase().contains("ender"))) {
hurtEntity.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, level * 200, Math.max(1, (5 * level) / 7)));
hurtEntity.addPotionEffect(new PotionEffect(MobEffects.POISON, level * 200, Math.max(1, (5 * level) / 7)));
}
}

}
27 changes: 7 additions & 20 deletions src/main/java/gregtech/common/ConfigHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ public class ConfigHolder {
@Config.RequiresMcRestart
public static boolean ignoreErrorOrInvalidRecipes = true;

@Config.Comment("Setting this to false causes GTCE to not register additional methane recipes for foods in the centrifuge. Default: true")
@Config.RequiresMcRestart
public static boolean addFoodMethaneRecipes = true;

@Config.Comment("Category that contains configs for changing vanilla recipes")
@Config.Name("Vanilla Recipe Options")
@Config.RequiresMcRestart
Expand Down Expand Up @@ -186,14 +182,6 @@ public static class UnofficialOptions {
@Config.RequiresMcRestart
public static boolean addLoot = true;

@Config.Comment("Should recipes for EV and IV Drills be enabled, which may cause large amounts of lag when used on some low-end devices? Default: true")
@Config.RequiresMcRestart
public boolean registerRecipesForHighTierDrills = true;

@Config.Comment("Should recipes for Mining Hammers be enabled? Default: true")
@Config.RequiresMcRestart
public boolean registerRecipesForMiningHammers = true;

@Config.Comment("Divisor for Recipe Duration per Overclock. Default: 2.0")
@Config.RangeDouble(min = 2.0, max = 3.0)
public double overclockDivisor = 2.0;
Expand Down Expand Up @@ -224,10 +212,6 @@ public static class GT5U {
@Config.RequiresMcRestart
public boolean harderRods = false;

@Config.Comment("Whether or not to use polymers instead of rare metals for Carbon Fibers. REMOVES THE CHANCED OUTPUT! Default: false")
@Config.RequiresMcRestart
public boolean polymerCarbonFiber = false;

@Config.Comment("The default color to overlay onto machines. \n16777215 (0xFFFFFF in decimal) is no coloring (default), and 13819135 (0xD2DCFF in decimal) is the classic blue from GT5. THIS IS SERVER SIDE!!!")
@Config.RequiresMcRestart
public int defaultPaintingColor = 0xFFFFFF;
Expand All @@ -237,7 +221,6 @@ public static class GT5U {
public int defaultInsulationColor = 0x777777;

@Config.Comment("Enable temperature based bonuses for the Electric Blast Furnace. Default: true")
@Config.RequiresMcRestart
public boolean ebfTemperatureBonuses = true;

@Config.Comment("Enable more challenging recipes for Electric Blast Furnace Coils. Default: true")
Expand All @@ -255,6 +238,10 @@ public static class GT5U {
@Config.Comment("Enable High-Tier solar panels (IV-UV). They will not have recipes. Default: false")
@Config.RequiresMcRestart
public boolean enableHighTierSolars = false;

@Config.Comment("Should EV and IV Drills be enabled, which may cause large amounts of lag when used on some low-end devices? Default: true")
@Config.RequiresMcRestart
public boolean enableHighTierDrills = true;
}

public static class GT6 {
Expand Down Expand Up @@ -335,15 +322,15 @@ public static class Equipment {

public static class BatPack {
@Config.Comment("Total LV BatPack capacity. Default: 600,000")
@Config.RangeInt(min = 0)
@Config.RangeInt(min = 1)
public int capacityLV = 600000;

@Config.Comment("Total MV BatPack capacity. Default: 2,400,000")
@Config.RangeInt(min = 0)
@Config.RangeInt(min = 1)
public int capacityMV = 2400000;

@Config.Comment("Total HV BatPack capacity. Default: 9,600,000")
@Config.RangeInt(min = 0)
@Config.RangeInt(min = 1)
public int capacityHV = 9600000;
}
}
Expand Down
28 changes: 22 additions & 6 deletions src/main/java/gregtech/common/EventHandlers.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gregtech.common;

import gregtech.api.GTValues;
import gregtech.common.items.behaviors.ToggleEnergyConsumerBehavior;
import net.minecraft.client.Minecraft;
import gregtech.api.capability.GregtechCapabilities;
import gregtech.api.capability.IElectricItem;
Expand All @@ -15,11 +16,14 @@
import gregtech.common.items.MetaItems;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.world.EnumDifficulty;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent;
Expand All @@ -41,13 +45,27 @@ public static void onEndermanTeleportEvent(EnderTeleportEvent event) {
}
}

@SubscribeEvent
public static void onEntitySpawn(LivingSpawnEvent.SpecialSpawn event) {
EntityLivingBase entity = event.getEntityLiving();
EnumDifficulty difficulty = entity.world.getDifficulty();
if (difficulty == EnumDifficulty.HARD && entity.getRNG().nextFloat() <= 0.03f) {
if (entity instanceof EntityZombie && ConfigHolder.nanoSaberConfiguration.zombieSpawnWithSabers) {
ItemStack itemStack = MetaItems.NANO_SABER.getInfiniteChargedStack();
ToggleEnergyConsumerBehavior.setItemActive(itemStack, true);
entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, itemStack);
((EntityZombie) entity).setDropChance(EntityEquipmentSlot.MAINHAND, 0.0f);
}
}
}

@SubscribeEvent
public static void onPlayerInteraction(PlayerInteractEvent.RightClickBlock event) {
ItemStack stack = event.getItemStack();
if (!stack.isEmpty() && stack.getItem() == Items.FLINT_AND_STEEL) {
if (!event.getWorld().isRemote
&& !event.getEntityPlayer().capabilities.isCreativeMode
&& event.getWorld().rand.nextInt(100) >= ConfigHolder.flintChanceToCreateFire) {
&& GTValues.RNG.nextInt(100) >= ConfigHolder.flintChanceToCreateFire) {
stack.damageItem(1, event.getEntityPlayer());
if (stack.getItemDamage() >= stack.getMaxDamage()) {
stack.shrink(1);
Expand All @@ -59,7 +77,7 @@ public static void onPlayerInteraction(PlayerInteractEvent.RightClickBlock event

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onRender(final TickEvent.RenderTickEvent event) {
public static void onRender(final TickEvent.RenderTickEvent event) {
final Minecraft mc = Minecraft.getMinecraft();
if (mc.inGameHasFocus && mc.world != null && !mc.gameSettings.showDebugInfo && Minecraft.isGuiEnabled()) {
final ItemStack item = mc.player.inventory.armorItemInSlot(EntityEquipmentSlot.CHEST.getIndex());
Expand All @@ -81,7 +99,7 @@ public void onRender(final TickEvent.RenderTickEvent event) {
}

@SubscribeEvent(priority = EventPriority.LOW)
public void onKeyInput(InputEvent.KeyInputEvent event) {
public static void onKeyInput(InputEvent.KeyInputEvent event) {
if (ArmorUtils.SIDE.isClient()) {
boolean needNewPacket = false;
for (Key key : Keybinds.REGISTERY) {
Expand All @@ -96,7 +114,7 @@ public void onKeyInput(InputEvent.KeyInputEvent event) {
}

@SubscribeEvent(priority = EventPriority.LOW)
public void onEntityLivingFallEvent(LivingFallEvent event) {
public static void onEntityLivingFallEvent(LivingFallEvent event) {
if (!event.getEntity().getEntityWorld().isRemote && event.getEntity() instanceof EntityLivingBase) {
EntityLivingBase entity = (EntityLivingBase) event.getEntity();
ItemStack armor = entity.getItemStackFromSlot(EntityEquipmentSlot.FEET);
Expand Down Expand Up @@ -140,6 +158,4 @@ public void onEntityLivingFallEvent(LivingFallEvent event) {
}
}
}


}
14 changes: 7 additions & 7 deletions src/main/java/gregtech/common/entities/DynamiteEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public void onUpdate() {
}

this.inGround = false;
this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
this.motionX *= this.rand.nextFloat() * 0.2F;
this.motionY *= this.rand.nextFloat() * 0.2F;
this.motionZ *= this.rand.nextFloat() * 0.2F;
}

Vec3d vec3d = new Vec3d(this.posX, this.posY, this.posZ);
Expand Down Expand Up @@ -128,12 +128,12 @@ public void onUpdate() {
f1 = 0.8F;
}

this.motionX *= (double) f1;
this.motionY *= (double) f1;
this.motionZ *= (double) f1;
this.motionX *= f1;
this.motionY *= f1;
this.motionZ *= f1;

if (!this.hasNoGravity()) {
this.motionY -= (double) f2;
this.motionY -= f2;
}

this.setPosition(this.posX, this.posY, this.posZ);
Expand Down
32 changes: 0 additions & 32 deletions src/main/java/gregtech/common/entities/EntitySpawnHandler.java

This file was deleted.

14 changes: 6 additions & 8 deletions src/main/java/gregtech/common/items/EnchantmentTableTweaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import gregtech.api.unification.stack.UnificationEntry;
import gregtech.api.util.GTLog;
import gregtech.api.util.SlotDelegate;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerEnchantment;
import net.minecraft.inventory.IInventory;
Expand All @@ -24,25 +21,26 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nonnull;

@EventBusSubscriber(modid = GTValues.MODID)
public class EnchantmentTableTweaks {

@SubscribeEvent
public static void onContainerOpen(PlayerContainerEvent.Open event) {
onContainerOpen(event.getEntityPlayer(), event.getContainer());
onContainerOpen(event.getContainer());
}

@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void onGuiOpen(GuiOpenEvent event) {
if (event.getGui() instanceof GuiContainer) {
GuiContainer guiContainer = (GuiContainer) event.getGui();
EntityPlayerSP playerSP = Minecraft.getMinecraft().player;
onContainerOpen(playerSP, guiContainer.inventorySlots);
onContainerOpen(guiContainer.inventorySlots);
}
}

private static void onContainerOpen(EntityPlayer player, Container container) {
private static void onContainerOpen(Container container) {
if (container instanceof ContainerEnchantment) {
//wrap in try-catch because such kind of tweaks is subject to breaking
//don't let it crash game if some mod borked it
Expand Down Expand Up @@ -89,7 +87,7 @@ public EnchantmentLapisSlot(Slot delegate) {
}

@Override
public boolean isItemValid(ItemStack stack) {
public boolean isItemValid(@Nonnull ItemStack stack) {
return super.isItemValid(stack) || isValidForEnchantment(stack);
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/gregtech/common/items/MetaItem1.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public void registerSubItems() {
CREDIT_CUPRONICKEL = addItem(1, "credit.cupronickel").setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Cupronickel, GTValues.M / 4)));
CREDIT_SILVER = addItem(2, "credit.silver").setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Silver, GTValues.M / 4))).setRarity(EnumRarity.UNCOMMON);
CREDIT_GOLD = addItem(3, "credit.gold").setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Gold, GTValues.M / 4))).setRarity(EnumRarity.UNCOMMON);
CREDIT_PLATINUM = addItem(4, "credit.platinum").setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Platinum, GTValues.M / 4))).setRarity(EnumRarity.EPIC);
CREDIT_OSMIUM = addItem(5, "credit.osmium").setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Osmium, GTValues.M / 4))).setRarity(EnumRarity.EPIC);
CREDIT_NAQUADAH = addItem(6, "credit.naquadah").setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Naquadah, GTValues.M / 4))).setRarity(EnumRarity.RARE);
CREDIT_NEUTRONIUM = addItem(7, "credit.neutronium").setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Neutronium, GTValues.M / 4))).setRarity(EnumRarity.RARE);
CREDIT_PLATINUM = addItem(4, "credit.platinum").setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Platinum, GTValues.M / 4))).setRarity(EnumRarity.RARE);
CREDIT_OSMIUM = addItem(5, "credit.osmium").setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Osmium, GTValues.M / 4))).setRarity(EnumRarity.RARE);
CREDIT_NAQUADAH = addItem(6, "credit.naquadah").setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Naquadah, GTValues.M / 4))).setRarity(EnumRarity.EPIC);
CREDIT_NEUTRONIUM = addItem(7, "credit.neutronium").setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Neutronium, GTValues.M / 4))).setRarity(EnumRarity.EPIC);

COIN_GOLD_ANCIENT = addItem(8, "coin.gold.ancient").
setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Gold, GTValues.M / 4))).setRarity(EnumRarity.RARE);
COIN_DOGE = addItem(9, "coin.doge")
.setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Brass, GTValues.M / 4))).setRarity(EnumRarity.RARE);
.setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Brass, GTValues.M / 4))).setRarity(EnumRarity.EPIC);
COIN_CHOCOLATE = addItem(10, "coin.chocolate")
.setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Gold, GTValues.M / 4)))
.addComponents(new FoodStats(1, 0.1F, false, true, OreDictUnifier.get(OrePrefix.foil, Materials.Gold), new RandomPotionEffect(MobEffects.SPEED, 200, 1, 10)));
Expand Down Expand Up @@ -166,7 +166,7 @@ public void registerSubItems() {
.addComponents(new LighterBehaviour(100)).setMaxStackSize(1);
TOOL_LIGHTER_PLATINUM = addItem(92, "tool.lighter.platinum")
.setMaterialInfo(new ItemMaterialInfo(new MaterialStack(Materials.Platinum, GTValues.M * 2)))
.addComponents(new LighterBehaviour(1000)).setMaxStackSize(1);
.addComponents(new LighterBehaviour(1000)).setMaxStackSize(1).setRarity(EnumRarity.UNCOMMON);

BOTTLE_PURPLE_DRINK = addItem(93, "bottle.purple.drink").addComponents(new FoodStats(8, 0.2F, true, true, new ItemStack(Items.GLASS_BOTTLE), new RandomPotionEffect(MobEffects.HASTE, 800, 1, 90)));

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/gregtech/common/items/MetaTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.ore.OrePrefix;
import gregtech.api.unification.stack.UnificationEntry;
import gregtech.common.ConfigHolder;
import gregtech.common.tools.*;
import gregtech.common.tools.largedrills.ToolDrills;
import net.minecraft.init.Enchantments;
Expand Down Expand Up @@ -134,6 +135,11 @@ public void registerSubItems() {
.addOreDict(ToolDictNames.craftingToolMiningDrill)
.addComponents(ElectricStats.createElectricItem(25600000L, 5L));

if (!ConfigHolder.U.GT5u.enableHighTierDrills) {
DRILL_EV.setInvisible();
DRILL_IV.setInvisible();
}

MINING_HAMMER = addItem(35, "tool.mining_hammer").setToolStats(new ToolMiningHammer())
.setFullRepairCost(14);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ private boolean tryRotateRailBlock(IBlockState blockState, World world, BlockPos
if (rotation >= BlockRailBase.EnumRailDirection.values().length) {
rotation = 0;
}
if (rotation >= 6 && !blockRailBase.isFlexibleRail(world, blockPos)) {
rotation = 0;
}
return world.setBlockState(blockPos, blockState.withProperty(blockRailBase.getShapeProperty(),
BlockRailBase.EnumRailDirection.values()[rotation]));
}


}
Loading

0 comments on commit c3cdf2e

Please sign in to comment.