fix: all the porting :D

This commit is contained in:
Michael Hillcox 2021-08-22 22:19:57 +01:00
parent 518ee0b4c1
commit d89e3f5d1d
22 changed files with 275 additions and 280 deletions

View file

@ -2,16 +2,20 @@ buildscript {
repositories { repositories {
maven { url = 'https://maven.minecraftforge.net' } maven { url = 'https://maven.minecraftforge.net' }
mavenCentral() mavenCentral()
maven { url = 'https://maven.parchmentmc.org' }
} }
dependencies { dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath 'org.parchmentmc:librarian:1.+'
} }
} }
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'idea' apply plugin: 'idea'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
apply plugin: 'net.minecraftforge.gradle'
version = "$mod_version" version = "$mod_version"
group = "de.ellpeck.actuallyadditions" group = "de.ellpeck.actuallyadditions"
@ -24,7 +28,7 @@ if (System.getenv('BUILD_NUMBER') != null) {
java.toolchain.languageVersion = JavaLanguageVersion.of(8) java.toolchain.languageVersion = JavaLanguageVersion.of(8)
minecraft { minecraft {
mappings channel: 'official', version: "${game_version}" mappings channel: 'parchment', version: "${parchment_version}-${game_version}"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

View file

@ -1,9 +1,16 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
# Actually Additions # Actually Additions
# TODO: check this version change is okay. # TODO: check this version change is okay.
mod_version=1.1.52 mod_version=1.1.52
# Forge # Forge
game_version=1.16.5 game_version=1.16.5
forge_version=36.2.2 forge_version=36.2.2
# Parchment (Mappings)
parchment_version=2021.08.08
# Other mods # Other mods
jei_version=1.16.4:7.6.1.71 jei_version=1.16.4:7.6.1.71

View file

@ -34,7 +34,6 @@ import de.ellpeck.actuallyadditions.mod.recipe.EmpowererHandler;
import de.ellpeck.actuallyadditions.mod.recipe.HairyBallHandler; import de.ellpeck.actuallyadditions.mod.recipe.HairyBallHandler;
import de.ellpeck.actuallyadditions.mod.tile.ActuallyTiles; import de.ellpeck.actuallyadditions.mod.tile.ActuallyTiles;
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker; import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
import de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
@ -69,17 +68,14 @@ public class ActuallyAdditions {
return new ItemStack(ActuallyItems.ITEM_BOOKLET.get()); return new ItemStack(ActuallyItems.ITEM_BOOKLET.get());
} }
}; };
public static final Logger LOGGER = LogManager.getLogger(NAME);
@Deprecated @Deprecated
public static ActuallyAdditions INSTANCE; public static ActuallyAdditions INSTANCE;
public static final Logger LOGGER = LogManager.getLogger(NAME);
// TODO: [port] eval // TODO: [port] eval
// static { // static {
// FluidRegistry.enableUniversalBucket(); // FluidRegistry.enableUniversalBucket();
// } // }
public static boolean commonCapsLoaded; public static boolean commonCapsLoaded;
public ActuallyAdditions() { public ActuallyAdditions() {
@ -104,7 +100,7 @@ public class ActuallyAdditions {
ActuallyAdditionsAPI.methodHandler = new MethodHandler(); ActuallyAdditionsAPI.methodHandler = new MethodHandler();
ActuallyAdditionsAPI.connectionHandler = new LaserRelayConnectionHandler(); ActuallyAdditionsAPI.connectionHandler = new LaserRelayConnectionHandler();
Lenses.init(); Lenses.init();
CompatUtil.registerCraftingTweaks(); // CompatUtil.registerCraftingTweaks();
commonCapsLoaded = false; // Loader.isModLoaded("commoncapabilities"); commonCapsLoaded = false; // Loader.isModLoaded("commoncapabilities");

View file

@ -20,6 +20,7 @@ import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -46,8 +47,8 @@ public class GuiEntry extends GuiBooklet {
if (!this.chapters.isEmpty()) { if (!this.chapters.isEmpty()) {
IBookletChapter lastChap = this.chapters.get(this.chapters.size() - 1); IBookletChapter lastChap = this.chapters.get(this.chapters.size() - 1);
this.pageAmount = lastChap == null this.pageAmount = lastChap == null
? 1 ? 1
: calcEntryPage(this.entry, lastChap, this.searchText) + 1; : calcEntryPage(this.entry, lastChap, this.searchText) + 1;
} else { } else {
this.pageAmount = 1; this.pageAmount = 1;
} }

View file

@ -1,37 +1,33 @@
/* ///*
* This file ("GuiConfiguration.java") is part of the Actually Additions mod for Minecraft. // * This file ("GuiConfiguration.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed // * It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at // * under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense // * http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions // * View the source code at https://github.com/Ellpeck/ActuallyAdditions
* // *
* © 2015-2017 Ellpeck // * © 2015-2017 Ellpeck
*/ // */
//
package de.ellpeck.actuallyadditions.mod.config; //package de.ellpeck.actuallyadditions.mod.config;
//
import java.util.ArrayList; //import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import java.util.List; //
//import java.util.ArrayList;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; //import java.util.List;
import net.minecraft.client.gui.GuiScreen; //
import net.minecraftforge.common.config.ConfigElement; //public class GuiConfiguration extends GuiConfig {
import net.minecraftforge.fml.client.config.GuiConfig; //
import net.minecraftforge.fml.client.config.IConfigElement; // public GuiConfiguration(GuiScreen parentScreen) {
// super(parentScreen, getConfigElements(), ActuallyAdditions.MODID, false, false, GuiConfig.getAbridgedConfigPath(ConfigurationHandler.config.toString()));
public class GuiConfiguration extends GuiConfig { // }
//
public GuiConfiguration(GuiScreen parentScreen) { // private static List<IConfigElement> getConfigElements() {
super(parentScreen, getConfigElements(), ActuallyAdditions.MODID, false, false, GuiConfig.getAbridgedConfigPath(ConfigurationHandler.config.toString())); // List<IConfigElement> list = new ArrayList<>();
} // for (int i = 0; i < ConfigCategories.values().length; i++) {
// ConfigCategories cat = ConfigCategories.values()[i];
private static List<IConfigElement> getConfigElements() { // ConfigurationHandler.config.setCategoryComment(cat.name, cat.comment);
List<IConfigElement> list = new ArrayList<>(); // list.add(new ConfigElement(ConfigurationHandler.config.getCategory(cat.name)));
for (int i = 0; i < ConfigCategories.values().length; i++) { // }
ConfigCategories cat = ConfigCategories.values()[i]; // return list;
ConfigurationHandler.config.setCategoryComment(cat.name, cat.comment); // }
list.add(new ConfigElement(ConfigurationHandler.config.getCategory(cat.name))); //}
}
return list;
}
}

View file

@ -14,8 +14,8 @@ import com.google.common.collect.Sets;
import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.item.IItemTier; import net.minecraft.item.IItemTier;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -35,8 +35,8 @@ public class ItemAxeAA extends ItemToolAA {
public float getDestroySpeed(ItemStack stack, BlockState state) { public float getDestroySpeed(ItemStack stack, BlockState state) {
Material material = state.getMaterial(); Material material = state.getMaterial();
return material != Material.WOOD && material != Material.PLANT && material != Material.VINE return material != Material.WOOD && material != Material.PLANT && material != Material.VINE
? super.getDestroySpeed(stack, state) ? super.getDestroySpeed(stack, state)
: this.speed; : this.speed;
} }
@Override @Override

View file

@ -14,18 +14,16 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ItemCrafterOnAStick extends ItemBase { public class ItemCrafterOnAStick extends ItemBase {
public ItemCrafterOnAStick() { public ItemCrafterOnAStick() {
super(name); super(ActuallyItems.defaultNonStacking());
this.setMaxStackSize(1);
} }
@Override @Override
@ -33,11 +31,6 @@ public class ItemCrafterOnAStick extends ItemBase {
if (!world.isClientSide) { if (!world.isClientSide) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.CRAFTER.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ); player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.CRAFTER.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
} }
return new ActionResult<>(EnumActionResult.SUCCESS, player.getItemInHand(hand)); return new ActionResult<>(ActionResultType.SUCCESS, player.getItemInHand(hand));
}
@Override
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
} }
} }

View file

@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.items;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerDrill; import de.ellpeck.actuallyadditions.mod.inventory.ContainerDrill;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
@ -27,23 +26,27 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.enchantment.Enchantments; import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.ai.attributes.Attribute;
import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResult; import net.minecraft.util.*;
import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nullable;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -67,10 +70,8 @@ public class ItemDrill extends ItemEnergy {
* @param stack The Drill * @param stack The Drill
*/ */
public static void loadSlotsFromNBT(IItemHandlerModifiable slots, ItemStack stack) { public static void loadSlotsFromNBT(IItemHandlerModifiable slots, ItemStack stack) {
CompoundNBT compound = stack.getTagCompound(); CompoundNBT compound = stack.getOrCreateTag();
if (compound != null) { TileEntityInventoryBase.loadSlots(slots, compound);
TileEntityInventoryBase.loadSlots(slots, compound);
}
} }
/** /**
@ -80,22 +81,22 @@ public class ItemDrill extends ItemEnergy {
* @param stack The Drill * @param stack The Drill
*/ */
public static void writeSlotsToNBT(IItemHandler slots, ItemStack stack) { public static void writeSlotsToNBT(IItemHandler slots, ItemStack stack) {
CompoundNBT compound = stack.getTagCompound(); CompoundNBT compound = stack.getOrCreateTag();
if (compound == null) {
compound = new CompoundNBT();
}
TileEntityInventoryBase.saveSlots(slots, compound); TileEntityInventoryBase.saveSlots(slots, compound);
stack.setTagCompound(compound); stack.setTag(compound);
} }
@Override @Override
//Places Blocks if the Placing Upgrade is installed public ActionResultType useOn(ItemUseContext context) {
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, EnumFacing side, float hitX, float hitY, float hitZ) { PlayerEntity player = context.getPlayer();
Hand hand = context.getHand();
ItemStack stack = player.getItemInHand(hand); ItemStack stack = player.getItemInHand(hand);
ItemStack upgrade = this.getHasUpgradeAsStack(stack, ItemDrillUpgrade.UpgradeType.PLACER); ItemStack upgrade = this.getHasUpgradeAsStack(stack, ItemDrillUpgrade.UpgradeType.PLACER);
if (StackUtil.isValid(upgrade)) { if (StackUtil.isValid(upgrade)) {
int slot = ItemDrillUpgrade.getSlotToPlaceFrom(upgrade); int slot = ItemDrillUpgrade.getSlotToPlaceFrom(upgrade);
if (slot >= 0 && slot < PlayerInventory.getHotbarSize()) { if (slot >= 0 && slot < 9) { // TODO: validate... old = PlayerInventory.getHotbarSize(); new = 9
ItemStack equip = player.inventory.getItem(slot); ItemStack equip = player.inventory.getItem(slot);
if (StackUtil.isValid(equip) && equip != stack) { if (StackUtil.isValid(equip) && equip != stack) {
ItemStack toPlaceStack = equip.copy(); ItemStack toPlaceStack = equip.copy();
@ -105,7 +106,7 @@ public class ItemDrill extends ItemEnergy {
//tryPlaceItemIntoWorld could throw an Exception //tryPlaceItemIntoWorld could throw an Exception
try { try {
//Places the Block into the World //Places the Block into the World
if (toPlaceStack.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) != EnumActionResult.FAIL) { if (toPlaceStack.useOn(context) != ActionResultType.FAIL) {
if (!player.isCreative()) { if (!player.isCreative()) {
WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack.copy()); WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack.copy());
} }
@ -113,17 +114,18 @@ public class ItemDrill extends ItemEnergy {
} }
//Notify the Player and log the Exception //Notify the Player and log the Exception
catch (Exception e) { catch (Exception e) {
ActuallyAdditions.LOGGER.error("Player " + player.getName() + " who should place a Block using a Drill at " + player.posX + ", " + player.posY + ", " + player.posZ + " in World " + world.provider.getDimension() + " threw an Exception! Don't let that happen again!"); ActuallyAdditions.LOGGER.error("Player " + player.getName() + " who should place a Block using a Drill at " + player.getX() + ", " + player.getY() + ", " + player.getZ() + " in World " + context.getLevel().dimension() + " threw an Exception! Don't let that happen again!");
} }
player.inventory.setItem(slot, player.getItemInHand(hand)); player.inventory.setItem(slot, player.getItemInHand(hand));
WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, stack); WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, stack);
return EnumActionResult.SUCCESS; return ActionResultType.SUCCESS;
} }
} }
} }
return EnumActionResult.FAIL;
return super.useOn(context);
} }
/** /**
@ -131,14 +133,10 @@ public class ItemDrill extends ItemEnergy {
* *
* @param stack The Drill * @param stack The Drill
* @param upgrade The Upgrade to be checked * @param upgrade The Upgrade to be checked
*
* @return The Upgrade, if it's installed * @return The Upgrade, if it's installed
*/ */
public ItemStack getHasUpgradeAsStack(ItemStack stack, ItemDrillUpgrade.UpgradeType upgrade) { public ItemStack getHasUpgradeAsStack(ItemStack stack, ItemDrillUpgrade.UpgradeType upgrade) {
CompoundNBT compound = stack.getTagCompound(); CompoundNBT compound = stack.getOrCreateTag();
if (compound == null) {
return StackUtil.getEmpty();
}
ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerDrill.SLOT_AMOUNT); ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerDrill.SLOT_AMOUNT);
loadSlotsFromNBT(inv, stack); loadSlotsFromNBT(inv, stack);
@ -158,7 +156,7 @@ public class ItemDrill extends ItemEnergy {
if (!world.isClientSide && player.isShiftKeyDown() && hand == Hand.MAIN_HAND) { if (!world.isClientSide && player.isShiftKeyDown() && hand == Hand.MAIN_HAND) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DRILL.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ); player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DRILL.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
} }
return new ActionResult<>(EnumActionResult.PASS, player.getItemInHand(hand)); return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand));
} }
@Override @Override
@ -178,31 +176,27 @@ public class ItemDrill extends ItemEnergy {
} }
@Override @Override
public EnumRarity getRarity(ItemStack stack) { public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType slot, ItemStack stack) {
return EnumRarity.EPIC; Multimap<Attribute, AttributeModifier> map = super.getAttributeModifiers(slot, stack);
}
@Override if (slot == EquipmentSlotType.MAINHAND) {
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { map.put(Attributes.ATTACK_DAMAGE, new AttributeModifier("Drill Modifier", this.getEnergyStored(stack) >= ENERGY_USE
Multimap<String, AttributeModifier> map = super.getAttributeModifiers(slot, stack); ? 8.0F
: 0.1F, AttributeModifier.Operation.ADDITION));
if (slot == EntityEquipmentSlot.MAINHAND) { map.put(Attributes.ATTACK_SPEED, new AttributeModifier("Tool Modifier", -2.5F, AttributeModifier.Operation.ADDITION));
map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Drill Modifier", this.getEnergyStored(stack) >= ENERGY_USE
? 8.0F
: 0.1F, 0));
map.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Tool Modifier", -2.5F, 0));
} }
return map; return map;
} }
@Override @Override
public float getDestroySpeed(ItemStack stack, BlockState state) { public float getDestroySpeed(ItemStack stack, BlockState state) {
return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack)
? this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state).isEmpty() || this.getToolClasses(stack).contains(state.getBlock().getHarvestTool(state)) ? this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state) || this.getToolClasses(stack).contains(state.getBlock().getHarvestTool(state))
? this.getEfficiencyFromUpgrade(stack) ? this.getEfficiencyFromUpgrade(stack)
: 1.0F : 1.0F
: 0.1F; : 0.1F;
} }
@Override @Override
@ -216,24 +210,24 @@ public class ItemDrill extends ItemEnergy {
} else { } else {
if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)) { if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)) {
ItemUtil.addEnchantment(stack, Enchantments.BLOCK_FORTUNE, this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II) ItemUtil.addEnchantment(stack, Enchantments.BLOCK_FORTUNE, this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II)
? 3 ? 3
: 1); : 1);
} }
} }
//Block hit //Block hit
RayTraceResult ray = WorldUtil.getNearestBlockWithDefaultReachDistance(player.level, player); RayTraceResult ray = WorldUtil.getNearestBlockWithDefaultReachDistance(player.level, player);
if (ray != null) { if (ray != null && ray.getType() == RayTraceResult.Type.BLOCK) {
BlockRayTraceResult trace = (BlockRayTraceResult) ray;
//Breaks the Blocks //Breaks the Blocks
if (!player.isShiftKeyDown() && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)) { if (!player.isShiftKeyDown() && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)) {
if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) { if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) {
toReturn = this.breakBlocks(stack, 2, player.level, pos, ray.sideHit, player); toReturn = this.breakBlocks(stack, 2, player.level, pos, trace.getDirection(), player);
} else { } else {
toReturn = this.breakBlocks(stack, 1, player.level, pos, ray.sideHit, player); toReturn = this.breakBlocks(stack, 1, player.level, pos, trace.getDirection(), player);
} }
} else { } else {
toReturn = this.breakBlocks(stack, 0, player.level, pos, ray.sideHit, player); toReturn = this.breakBlocks(stack, 0, player.level, pos, trace.getDirection(), player);
} }
//Removes Enchantments added above //Removes Enchantments added above
@ -245,11 +239,10 @@ public class ItemDrill extends ItemEnergy {
} }
@Override @Override
public boolean canHarvestBlock(BlockState state, ItemStack stack) { public boolean canHarvestBlock(ItemStack stack, BlockState state) {
Block block = state.getBlock();
return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) && (this.hasExtraWhitelist(block) || state.getMaterial().isToolNotRequired() || block == Blocks.SNOW_LAYER || block == Blocks.SNOW || (block == Blocks.OBSIDIAN return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) && (this.hasExtraWhitelist(block) || state.getMaterial().isToolNotRequired() || block == Blocks.SNOW_LAYER || block == Blocks.SNOW || (block == Blocks.OBSIDIAN
? HARVEST_LEVEL >= 3 ? HARVEST_LEVEL >= 3
: block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE : block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE
? block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK ? block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK
? block != Blocks.GOLD_BLOCK && block != Blocks.GOLD_ORE ? block != Blocks.GOLD_BLOCK && block != Blocks.GOLD_ORE
? block != Blocks.IRON_BLOCK && block != Blocks.IRON_ORE ? block != Blocks.IRON_BLOCK && block != Blocks.IRON_ORE
@ -273,7 +266,7 @@ public class ItemDrill extends ItemEnergy {
} }
@Override @Override
public int getHarvestLevel(ItemStack stack, String toolClass, PlayerEntity player, BlockState blockState) { public int getHarvestLevel(ItemStack stack, ToolType p_getHarvestLevel_2_, @Nullable PlayerEntity p_getHarvestLevel_3_, @Nullable BlockState p_getHarvestLevel_4_) {
return HARVEST_LEVEL; return HARVEST_LEVEL;
} }
@ -281,7 +274,6 @@ public class ItemDrill extends ItemEnergy {
* Gets the Energy that is used per Block broken * Gets the Energy that is used per Block broken
* *
* @param stack The Drill * @param stack The Drill
*
* @return The Energy use per Block * @return The Energy use per Block
*/ */
public int getEnergyUsePerBlock(ItemStack stack) { public int getEnergyUsePerBlock(ItemStack stack) {
@ -327,21 +319,12 @@ public class ItemDrill extends ItemEnergy {
* *
* @param stack The Drill * @param stack The Drill
* @param upgrade The Upgrade to be checked * @param upgrade The Upgrade to be checked
*
* @return Is the Upgrade applied? * @return Is the Upgrade applied?
*/ */
public boolean getHasUpgrade(ItemStack stack, ItemDrillUpgrade.UpgradeType upgrade) { public boolean getHasUpgrade(ItemStack stack, ItemDrillUpgrade.UpgradeType upgrade) {
return StackUtil.isValid(this.getHasUpgradeAsStack(stack, upgrade)); return StackUtil.isValid(this.getHasUpgradeAsStack(stack, upgrade));
} }
@Override
protected void registerRendering() {
for (int i = 0; i < 16; i++) {
String name = this.getRegistryName() + "_" + TheColoredLampColors.values()[i].regName;
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(name), "inventory");
}
}
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void getSubItems(CreativeTabs tabs, NonNullList<ItemStack> list) { public void getSubItems(CreativeTabs tabs, NonNullList<ItemStack> list) {
@ -366,7 +349,6 @@ public class ItemDrill extends ItemEnergy {
* Gets the Mining Speed of the Drill * Gets the Mining Speed of the Drill
* *
* @param stack The Drill * @param stack The Drill
*
* @return The Mining Speed depending on the Speed Upgrades * @return The Mining Speed depending on the Speed Upgrades
*/ */
public float getEfficiencyFromUpgrade(ItemStack stack) { public float getEfficiencyFromUpgrade(ItemStack stack) {
@ -400,17 +382,17 @@ public class ItemDrill extends ItemEnergy {
* @param world The World * @param world The World
* @param player The Player who breaks the Blocks * @param player The Player who breaks the Blocks
*/ */
public boolean breakBlocks(ItemStack stack, int radius, World world, BlockPos aPos, EnumFacing side, PlayerEntity player) { public boolean breakBlocks(ItemStack stack, int radius, World world, BlockPos aPos, Direction side, PlayerEntity player) {
int xRange = radius; int xRange = radius;
int yRange = radius; int yRange = radius;
int zRange = 0; int zRange = 0;
//Corrects Blocks to hit depending on Side of original Block hit //Corrects Blocks to hit depending on Side of original Block hit
if (side.getAxis() == Axis.Y) { if (side.getAxis() == Direction.Axis.Y) {
zRange = radius; zRange = radius;
yRange = 0; yRange = 0;
} }
if (side.getAxis() == Axis.X) { if (side.getAxis() == Direction.Axis.X) {
xRange = 0; xRange = 0;
zRange = radius; zRange = radius;
} }
@ -429,7 +411,7 @@ public class ItemDrill extends ItemEnergy {
return false; return false;
} }
if (radius == 2 && side.getAxis() != Axis.Y) { if (radius == 2 && side.getAxis() != Direction.Axis.Y) {
aPos = aPos.above(); aPos = aPos.above();
BlockState theState = world.getBlockState(aPos); BlockState theState = world.getBlockState(aPos);
if (theState.getDestroySpeed(world, aPos) <= mainHardness + 5.0F) { if (theState.getDestroySpeed(world, aPos) <= mainHardness + 5.0F) {
@ -476,7 +458,7 @@ public class ItemDrill extends ItemEnergy {
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
Block block = state.getBlock(); Block block = state.getBlock();
float hardness = state.getDestroySpeed(world, pos); float hardness = state.getDestroySpeed(world, pos);
boolean canHarvest = (ForgeHooks.canHarvestBlock(block, player, world, pos) || this.canHarvestBlock(state, stack)) && (!isExtra || this.getDestroySpeed(stack, world.getBlockState(pos)) > 1.0F); boolean canHarvest = (ForgeHooks.canHarvestBlock(state, player, world, pos) || this.canHarvestBlock(stack, state)) && (!isExtra || this.getDestroySpeed(stack, world.getBlockState(pos)) > 1.0F);
if (hardness >= 0.0F && (!isExtra || canHarvest && !block.hasTileEntity(world.getBlockState(pos)))) { if (hardness >= 0.0F && (!isExtra || canHarvest && !block.hasTileEntity(world.getBlockState(pos)))) {
if (!player.isCreative()) { if (!player.isCreative()) {
this.extractEnergyInternal(stack, use, false); this.extractEnergyInternal(stack, use, false);

View file

@ -15,7 +15,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -41,20 +41,16 @@ public class ItemDrillUpgrade extends ItemBase {
ItemStack stack = player.getItemInHand(hand); ItemStack stack = player.getItemInHand(hand);
if (!world.isClientSide && this.type == UpgradeType.PLACER) { if (!world.isClientSide && this.type == UpgradeType.PLACER) {
this.setSlotToPlaceFrom(stack, player.inventory.selected); this.setSlotToPlaceFrom(stack, player.inventory.selected);
return new ActionResult<>(EnumActionResult.SUCCESS, stack); return new ActionResult<>(ActionResultType.SUCCESS, stack);
} }
return new ActionResult<>(EnumActionResult.FAIL, stack); return new ActionResult<>(ActionResultType.FAIL, stack);
} }
public void setSlotToPlaceFrom(ItemStack stack, int slot) { public void setSlotToPlaceFrom(ItemStack stack, int slot) {
CompoundNBT compound = stack.getTagCompound(); CompoundNBT compound = stack.getOrCreateTag();
if (compound == null) {
compound = new CompoundNBT();
}
compound.putInt("SlotToPlaceFrom", slot + 1); compound.putInt("SlotToPlaceFrom", slot + 1);
stack.setTagCompound(compound); stack.setTag(compound);
} }
public enum UpgradeType { public enum UpgradeType {

View file

@ -16,10 +16,10 @@ import de.ellpeck.actuallyadditions.mod.items.metalists.TheDusts;
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class ItemDust extends ItemBase implements IColorProvidingItem { public class ItemDust extends ItemBase implements IColorProvidingItem {
@ -39,15 +39,15 @@ public class ItemDust extends ItemBase implements IColorProvidingItem {
@Override @Override
public String getDescriptionId(ItemStack stack) { public String getDescriptionId(ItemStack stack) {
return stack.getItemDamage() >= ALL_DUSTS.length return stack.getItemDamage() >= ALL_DUSTS.length
? StringUtil.BUGGED_ITEM_NAME ? StringUtil.BUGGED_ITEM_NAME
: this.getDescriptionId() + "_" + ALL_DUSTS[stack.getItemDamage()].name; : this.getDescriptionId() + "_" + ALL_DUSTS[stack.getItemDamage()].name;
} }
@Override @Override
public EnumRarity getRarity(ItemStack stack) { public EnumRarity getRarity(ItemStack stack) {
return stack.getItemDamage() >= ALL_DUSTS.length return stack.getItemDamage() >= ALL_DUSTS.length
? EnumRarity.COMMON ? EnumRarity.COMMON
: ALL_DUSTS[stack.getItemDamage()].rarity; : ALL_DUSTS[stack.getItemDamage()].rarity;
} }
@Override @Override
@ -71,8 +71,8 @@ public class ItemDust extends ItemBase implements IColorProvidingItem {
@Override @Override
public IItemColor getItemColor() { public IItemColor getItemColor() {
return (stack, pass) -> stack.getItemDamage() >= ALL_DUSTS.length return (stack, pass) -> stack.getItemDamage() >= ALL_DUSTS.length
? 0xFFFFFF ? 0xFFFFFF
: ALL_DUSTS[stack.getItemDamage()].color; : ALL_DUSTS[stack.getItemDamage()].color;
} }
@Override @Override

View file

@ -13,38 +13,28 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.misc.DispenserHandlerFertilize; import de.ellpeck.actuallyadditions.mod.misc.DispenserHandlerFertilize;
import net.minecraft.block.DispenserBlock; import net.minecraft.block.DispenserBlock;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BoneMealItem;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction; import net.minecraft.item.ItemUseContext;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class ItemFertilizer extends ItemBase { public class ItemFertilizer extends ItemBase {
public ItemFertilizer() { public ItemFertilizer() {
super(name); super();
DispenserBlock.registerBehavior(this, new DispenserHandlerFertilize()); DispenserBlock.registerBehavior(this, new DispenserHandlerFertilize());
} }
@Override @Override
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction side, float par8, float par9, float par10) { public ActionResultType useOn(ItemUseContext context) {
ItemStack stack = player.getItemInHand(hand); ItemStack stack = context.getPlayer().getItemInHand(context.getHand());
if (ItemDye.applyBonemeal(stack, world, pos, player, hand)) { if (BoneMealItem.applyBonemeal(stack, context.getLevel(), context.getClickedPos(), context.getPlayer())) {
if (!world.isClientSide) { if (!context.getLevel().isClientSide) {
world.levelEvent(2005, pos, 0); context.getLevel().levelEvent(2005, context.getClickedPos(), 0);
} }
return EnumActionResult.SUCCESS; return ActionResultType.SUCCESS;
} }
return super.useOn(player, world, pos, hand, side, par8, par9, par10); return super.useOn(context);
}
@Override
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
} }
} }

View file

@ -15,9 +15,7 @@ import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumAction; import net.minecraft.item.EnumAction;
@ -25,6 +23,8 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class ItemFoods extends ItemFoodBase { public class ItemFoods extends ItemFoodBase {

View file

@ -11,10 +11,10 @@
package de.ellpeck.actuallyadditions.mod.network; package de.ellpeck.actuallyadditions.mod.network;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.network.NetworkEvent;
public interface IDataHandler { public interface IDataHandler {
void handleData(CompoundNBT compound, MessageContext context); void handleData(CompoundNBT compound, NetworkEvent.Context context);
} }

View file

@ -14,10 +14,7 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.network.NetworkEvent;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
public class PacketClientToServer { public class PacketClientToServer {
@ -59,7 +56,7 @@ public class PacketClientToServer {
public static class Handler implements IMessageHandler<PacketClientToServer, IMessage> { public static class Handler implements IMessageHandler<PacketClientToServer, IMessage> {
@Override @Override
public IMessage onMessage(PacketClientToServer message, MessageContext ctx) { public IMessage onMessage(PacketClientToServer message, NetworkEvent.Context ctx) {
FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(() -> { FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(() -> {
if (message.data != null && message.handler != null) { if (message.data != null && message.handler != null) {
message.handler.handleData(message.data, ctx); message.handler.handleData(message.data, ctx);

View file

@ -33,7 +33,7 @@ public final class PacketHandlerHelper {
compound.putInt("X", pos.getX()); compound.putInt("X", pos.getX());
compound.putInt("Y", pos.getY()); compound.putInt("Y", pos.getY());
compound.putInt("Z", pos.getZ()); compound.putInt("Z", pos.getZ());
compound.putInt("WorldID", tile.getLevel().provider.getDimension()); compound.putInt("WorldID", tile.getLevel().getDimension());
compound.putInt("PlayerID", Minecraft.getInstance().player.getId()); compound.putInt("PlayerID", Minecraft.getInstance().player.getId());
compound.putInt("ButtonID", buttonId); compound.putInt("ButtonID", buttonId);
PacketHandler.THE_NETWORK.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER)); PacketHandler.THE_NETWORK.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));

View file

@ -15,12 +15,14 @@ import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
public class PacketServerToClient implements IMessage { public class PacketServerToClient implements Message {
private CompoundNBT data; private CompoundNBT data;
private IDataHandler handler; private IDataHandler handler;

View file

@ -20,10 +20,7 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureManager;
@ -72,7 +69,7 @@ public final class AssetUtil {
public static void renderItemInWorld(ItemStack stack, int combinedLight, int combinedOverlay, MatrixStack matrices, IRenderTypeBuffer buffer) { public static void renderItemInWorld(ItemStack stack, int combinedLight, int combinedOverlay, MatrixStack matrices, IRenderTypeBuffer buffer) {
if (StackUtil.isValid(stack)) { if (StackUtil.isValid(stack)) {
Minecraft.getInstance().getItemRenderer().renderStatic( Minecraft.getInstance().getItemRenderer().renderStatic(
stack, ItemCameraTransforms.TransformType.FIXED, combinedLight, combinedOverlay, matrices, buffer stack, ItemCameraTransforms.TransformType.FIXED, combinedLight, combinedOverlay, matrices, buffer
); );
} }
} }
@ -95,7 +92,7 @@ public final class AssetUtil {
public static void renderItemWithoutScrewingWithColors(ItemStack stack) { public static void renderItemWithoutScrewingWithColors(ItemStack stack) {
if (StackUtil.isValid(stack)) { if (StackUtil.isValid(stack)) {
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
RenderItem renderer = mc.getRenderItem(); ItemRenderer renderer = mc.getItemRenderer();
TextureManager manager = mc.getTextureManager(); TextureManager manager = mc.getTextureManager();
IBakedModel model = renderer.getItemModelWithOverrides(stack, null, null); IBakedModel model = renderer.getItemModelWithOverrides(stack, null, null);
@ -105,7 +102,7 @@ public final class AssetUtil {
GlStateManager._enableRescaleNormal(); GlStateManager._enableRescaleNormal();
GlStateManager._enableBlend(); GlStateManager._enableBlend();
GlStateManager._pushMatrix(); GlStateManager._pushMatrix();
model = ForgeHooksClient.handleCameraTransforms(model, TransformType.FIXED, false); model = ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.FIXED, false);
renderer.renderItem(stack, model); renderer.renderItem(stack, model);
GlStateManager.cullFace(GlStateManager.CullFace.BACK); GlStateManager.cullFace(GlStateManager.CullFace.BACK);
GlStateManager._popMatrix(); GlStateManager._popMatrix();
@ -253,8 +250,8 @@ public final class AssetUtil {
Vec3d combinedVec = vec2.subtract(vec1); Vec3d combinedVec = vec2.subtract(vec1);
double rot = rotationTime > 0 double rot = rotationTime > 0
? 360D * (world.getTotalWorldTime() % rotationTime / rotationTime) ? 360D * (world.getTotalWorldTime() % rotationTime / rotationTime)
: 0; : 0;
double pitch = Math.atan2(combinedVec.y, Math.sqrt(combinedVec.x * combinedVec.x + combinedVec.z * combinedVec.z)); double pitch = Math.atan2(combinedVec.y, Math.sqrt(combinedVec.x * combinedVec.x + combinedVec.z * combinedVec.z));
double yaw = Math.atan2(-combinedVec.z, combinedVec.x); double yaw = Math.atan2(-combinedVec.z, combinedVec.x);

View file

@ -11,11 +11,14 @@
package de.ellpeck.actuallyadditions.mod.util; package de.ellpeck.actuallyadditions.mod.util;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMapperBase; import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;

View file

@ -11,10 +11,11 @@
package de.ellpeck.actuallyadditions.mod.util; package de.ellpeck.actuallyadditions.mod.util;
import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public interface IColorProvidingBlock { public interface IColorProvidingBlock {
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
IBlockColor getBlockColor(); IBlockColor getBlockColor();

View file

@ -11,10 +11,11 @@
package de.ellpeck.actuallyadditions.mod.util; package de.ellpeck.actuallyadditions.mod.util;
import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.renderer.color.IItemColor;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public interface IColorProvidingItem { public interface IColorProvidingItem {
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
IItemColor getItemColor(); IItemColor getItemColor();

View file

@ -1,49 +1,23 @@
package de.ellpeck.actuallyadditions.mod.util; package de.ellpeck.actuallyadditions.mod.util;
import java.util.Set; import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.network.EnumPacketDirection; import net.minecraft.network.IPacket;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet; import net.minecraft.network.PacketDirection;
import net.minecraft.network.play.client.CPacketAnimation; import net.minecraft.network.play.ServerPlayNetHandler;
import net.minecraft.network.play.client.CPacketChatMessage; import net.minecraft.network.play.client.*;
import net.minecraft.network.play.client.CPacketClickWindow; import net.minecraft.network.play.server.SPlayerPositionLookPacket;
import net.minecraft.network.play.client.CPacketClientSettings;
import net.minecraft.network.play.client.CPacketClientStatus;
import net.minecraft.network.play.client.CPacketCloseWindow;
import net.minecraft.network.play.client.CPacketConfirmTeleport;
import net.minecraft.network.play.client.CPacketConfirmTransaction;
import net.minecraft.network.play.client.CPacketCreativeInventoryAction;
import net.minecraft.network.play.client.CPacketCustomPayload;
import net.minecraft.network.play.client.CPacketEnchantItem;
import net.minecraft.network.play.client.CPacketEntityAction;
import net.minecraft.network.play.client.CPacketHeldItemChange;
import net.minecraft.network.play.client.CPacketInput;
import net.minecraft.network.play.client.CPacketKeepAlive;
import net.minecraft.network.play.client.CPacketPlaceRecipe;
import net.minecraft.network.play.client.CPacketPlayer;
import net.minecraft.network.play.client.CPacketPlayerAbilities;
import net.minecraft.network.play.client.CPacketPlayerDigging;
import net.minecraft.network.play.client.CPacketPlayerTryUseItem;
import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock;
import net.minecraft.network.play.client.CPacketRecipeInfo;
import net.minecraft.network.play.client.CPacketResourcePackStatus;
import net.minecraft.network.play.client.CPacketSeenAdvancements;
import net.minecraft.network.play.client.CPacketSpectate;
import net.minecraft.network.play.client.CPacketSteerBoat;
import net.minecraft.network.play.client.CPacketTabComplete;
import net.minecraft.network.play.client.CPacketUpdateSign;
import net.minecraft.network.play.client.CPacketUseEntity;
import net.minecraft.network.play.client.CPacketVehicleMove;
import net.minecraft.network.play.server.SPacketPlayerPosLook.EnumFlags;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
public class NetHandlerSpaghettiServer extends NetHandlerPlayServer { import javax.annotation.Nullable;
import java.util.Set;
public class NetHandlerSpaghettiServer extends ServerPlayNetHandler {
public NetHandlerSpaghettiServer(FakePlayer player) { public NetHandlerSpaghettiServer(FakePlayer player) {
super(null, new NetworkManager(EnumPacketDirection.CLIENTBOUND), player); super(null, new NetworkManager(PacketDirection.CLIENTBOUND), player);
} }
@Override @Override
@ -51,140 +25,202 @@ public class NetHandlerSpaghettiServer extends NetHandlerPlayServer {
} }
@Override @Override
public void handlePlaceRecipe(CPacketPlaceRecipe p_194308_1_) { public void handlePlayerInput(CInputPacket p_147358_1_) {
} }
@Override @Override
public void handleAnimation(CPacketAnimation packetIn) { public void handleMoveVehicle(CMoveVehiclePacket p_184338_1_) {
} }
@Override @Override
public void handleRecipeBookUpdate(CPacketRecipeInfo p_191984_1_) { public void handleAcceptTeleportPacket(CConfirmTeleportPacket p_184339_1_) {
} }
@Override @Override
public void handleResourcePackStatus(CPacketResourcePackStatus packetIn) { public void handleRecipeBookSeenRecipePacket(CMarkRecipeSeenPacket p_191984_1_) {
} }
@Override @Override
public void handleSeenAdvancements(CPacketSeenAdvancements p_194027_1_) { public void handleRecipeBookChangeSettingsPacket(CUpdateRecipeBookStatusPacket p_241831_1_) {
} }
@Override @Override
public void handleSpectate(CPacketSpectate packetIn) { public void handleSeenAdvancements(CSeenAdvancementsPacket p_194027_1_) {
} }
@Override @Override
public void onDisconnect(ITextComponent reason) { public void handleCustomCommandSuggestions(CTabCompletePacket p_195518_1_) {
} }
@Override @Override
public void processChatMessage(CPacketChatMessage packetIn) { public void handleSetCommandBlock(CUpdateCommandBlockPacket p_210153_1_) {
} }
@Override @Override
public void processClickWindow(CPacketClickWindow packetIn) { public void handleSetCommandMinecart(CUpdateMinecartCommandBlockPacket p_210158_1_) {
} }
@Override @Override
public void processClientSettings(CPacketClientSettings packetIn) { public void handlePickItem(CPickItemPacket p_210152_1_) {
} }
@Override @Override
public void processClientStatus(CPacketClientStatus packetIn) { public void handleRenameItem(CRenameItemPacket p_210155_1_) {
} }
@Override @Override
public void processCloseWindow(CPacketCloseWindow packetIn) { public void handleSetBeaconPacket(CUpdateBeaconPacket p_210154_1_) {
} }
@Override @Override
public void processConfirmTeleport(CPacketConfirmTeleport packetIn) { public void handleSetStructureBlock(CUpdateStructureBlockPacket p_210157_1_) {
} }
@Override @Override
public void processConfirmTransaction(CPacketConfirmTransaction packetIn) { public void handleSetJigsawBlock(CUpdateJigsawBlockPacket p_217262_1_) {
} }
@Override @Override
public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn) { public void handleJigsawGenerate(CJigsawBlockGeneratePacket p_230549_1_) {
} }
@Override @Override
public void processCustomPayload(CPacketCustomPayload packetIn) { public void handleSelectTrade(CSelectTradePacket p_210159_1_) {
} }
@Override @Override
public void processEnchantItem(CPacketEnchantItem packetIn) { public void handleEditBook(CEditBookPacket p_210156_1_) {
} }
@Override @Override
public void processEntityAction(CPacketEntityAction packetIn) { public void handleEntityTagQuery(CQueryEntityNBTPacket p_211526_1_) {
} }
@Override @Override
public void processHeldItemChange(CPacketHeldItemChange packetIn) { public void handleBlockEntityTagQuery(CQueryTileEntityNBTPacket p_211525_1_) {
} }
@Override @Override
public void processInput(CPacketInput packetIn) { public void handleMovePlayer(CPlayerPacket p_147347_1_) {
} }
@Override @Override
public void processKeepAlive(CPacketKeepAlive packetIn) { public void teleport(double p_147364_1_, double p_147364_3_, double p_147364_5_, float p_147364_7_, float p_147364_8_) {
} }
@Override @Override
public void processPlayer(CPacketPlayer packetIn) { public void teleport(double p_175089_1_, double p_175089_3_, double p_175089_5_, float p_175089_7_, float p_175089_8_, Set<SPlayerPositionLookPacket.Flags> p_175089_9_) {
} }
@Override @Override
public void processPlayerAbilities(CPacketPlayerAbilities packetIn) { public void handlePlayerAction(CPlayerDiggingPacket p_147345_1_) {
} }
@Override @Override
public void processPlayerDigging(CPacketPlayerDigging packetIn) { public void handleUseItemOn(CPlayerTryUseItemOnBlockPacket p_184337_1_) {
} }
@Override @Override
public void processSteerBoat(CPacketSteerBoat packetIn) { public void handleUseItem(CPlayerTryUseItemPacket p_147346_1_) {
} }
@Override @Override
public void processTabComplete(CPacketTabComplete packetIn) { public void handleTeleportToEntityPacket(CSpectatePacket p_175088_1_) {
} }
@Override @Override
public void processTryUseItem(CPacketPlayerTryUseItem packetIn) { public void handleResourcePackResponse(CResourcePackStatusPacket p_175086_1_) {
} }
@Override @Override
public void processTryUseItemOnBlock(CPacketPlayerTryUseItemOnBlock packetIn) { public void handlePaddleBoat(CSteerBoatPacket p_184340_1_) {
} }
@Override @Override
public void processUpdateSign(CPacketUpdateSign packetIn) { public void onDisconnect(ITextComponent p_147231_1_) {
} }
@Override @Override
public void processUseEntity(CPacketUseEntity packetIn) { public void send(IPacket<?> p_147359_1_) {
} }
@Override @Override
public void processVehicleMove(CPacketVehicleMove packetIn) { public void send(IPacket<?> p_211148_1_, @Nullable GenericFutureListener<? extends Future<? super Void>> p_211148_2_) {
} }
@Override @Override
public void sendPacket(Packet<?> packetIn) { public void handleSetCarriedItem(CHeldItemChangePacket p_147355_1_) {
} }
@Override @Override
public void setPlayerLocation(double x, double y, double z, float yaw, float pitch) { public void handleChat(CChatMessagePacket p_147354_1_) {
} }
@Override @Override
public void setPlayerLocation(double x, double y, double z, float yaw, float pitch, Set<EnumFlags> relativeSet) { public void handleAnimate(CAnimateHandPacket p_175087_1_) {
} }
@Override
public void handlePlayerCommand(CEntityActionPacket p_147357_1_) {
}
@Override
public void handleInteract(CUseEntityPacket p_147340_1_) {
}
@Override
public void handleClientCommand(CClientStatusPacket p_147342_1_) {
}
@Override
public void handleContainerClose(CCloseWindowPacket p_147356_1_) {
}
@Override
public void handleContainerClick(CClickWindowPacket p_147351_1_) {
}
@Override
public void handlePlaceRecipe(CPlaceRecipePacket p_194308_1_) {
}
@Override
public void handleContainerButtonClick(CEnchantItemPacket p_147338_1_) {
}
@Override
public void handleSetCreativeModeSlot(CCreativeInventoryActionPacket p_147344_1_) {
}
@Override
public void handleContainerAck(CConfirmTransactionPacket p_147339_1_) {
}
@Override
public void handleSignUpdate(CUpdateSignPacket p_147343_1_) {
}
@Override
public void handleKeepAlive(CKeepAlivePacket p_147353_1_) {
}
@Override
public void handlePlayerAbilities(CPlayerAbilitiesPacket p_147348_1_) {
}
@Override
public void handleClientInformation(CClientSettingsPacket p_147352_1_) {
}
@Override
public void handleCustomPayload(CCustomPayloadPacket p_147349_1_) {
}
@Override
public void handleChangeDifficulty(CSetDifficultyPacket p_217263_1_) {
}
@Override
public void handleLockDifficulty(CLockDifficultyPacket p_217261_1_) {
}
} }

View file

@ -25,7 +25,6 @@ public final class StackUtil {
* Pretty much just a check for {@link ItemStack#isEmpty()} but exists in case Mojang does some more refactoring. * Pretty much just a check for {@link ItemStack#isEmpty()} but exists in case Mojang does some more refactoring.
* *
* @param stack The stack * @param stack The stack
*
* @return If the stack is not empty, or if it's an IDisableableItem, if its enabled. * @return If the stack is not empty, or if it's an IDisableableItem, if its enabled.
*/ */
@Deprecated @Deprecated
@ -49,7 +48,6 @@ public final class StackUtil {
* Checks if a collection of stacks are empty, as {@link Collection#isEmpty()} does not care about empty stacks. * Checks if a collection of stacks are empty, as {@link Collection#isEmpty()} does not care about empty stacks.
* *
* @param stacks Some ItemStacks * @param stacks Some ItemStacks
*
* @return If all stacks in the collection return true for {@link ItemStack#isEmpty()} * @return If all stacks in the collection return true for {@link ItemStack#isEmpty()}
*/ */
@Deprecated @Deprecated
@ -71,7 +69,6 @@ public final class StackUtil {
* @param inv The AA Item handler * @param inv The AA Item handler
* @param stacks The stacks to add * @param stacks The stacks to add
* @param fromAutomation If these stacks are coming from a pipe or other external source, or internally, like from the TE's update() method. * @param fromAutomation If these stacks are coming from a pipe or other external source, or internally, like from the TE's update() method.
*
* @return If all stacks fit fully. If even one item would not fit, the method returns false. * @return If all stacks fit fully. If even one item would not fit, the method returns false.
*/ */
public static boolean canAddAll(ItemStackHandlerAA inv, List<ItemStack> stacks, boolean fromAutomation) { public static boolean canAddAll(ItemStackHandlerAA inv, List<ItemStack> stacks, boolean fromAutomation) {
@ -118,7 +115,6 @@ public final class StackUtil {
* @param slot The starting slot. * @param slot The starting slot.
* @param endSlot The ending slot, exclusive. * @param endSlot The ending slot, exclusive.
* @param fromAutomation If these stacks are coming from a pipe or other external source, or internally, like from the TE's update() method. * @param fromAutomation If these stacks are coming from a pipe or other external source, or internally, like from the TE's update() method.
*
* @return If all stacks fit fully. If even one item would not fit, the method returns false. * @return If all stacks fit fully. If even one item would not fit, the method returns false.
*/ */
public static boolean canAddAll(ItemStackHandlerAA inv, List<ItemStack> stacks, int slot, int endSlot, boolean fromAutomation) { public static boolean canAddAll(ItemStackHandlerAA inv, List<ItemStack> stacks, int slot, int endSlot, boolean fromAutomation) {
@ -162,7 +158,6 @@ public final class StackUtil {
* Util method to find the first filled item in a handler. Searches from slot 0 to the end. * Util method to find the first filled item in a handler. Searches from slot 0 to the end.
* *
* @param inv The IItemHandler to search. * @param inv The IItemHandler to search.
*
* @return The first filled slot, or -1 if all slots are empty. * @return The first filled slot, or -1 if all slots are empty.
*/ */
public static int findFirstFilled(IItemHandler inv) { public static int findFirstFilled(IItemHandler inv) {
@ -210,17 +205,15 @@ public final class StackUtil {
* @param simulate If this is a simulation * @param simulate If this is a simulation
* @param slotStart Start range * @param slotStart Start range
* @param slotEnd End range * @param slotEnd End range
*
* @return The remainder that was not inserted. * @return The remainder that was not inserted.
*/ */
public static ItemStack insertItem(SlotlessableItemHandlerWrapper wrapper, ItemStack stack, boolean simulate, int slotStart, int slotEnd) { public static ItemStack insertItem(SlotlessableItemHandlerWrapper wrapper, ItemStack stack, boolean simulate, int slotStart, int slotEnd) {
if (stack.isEmpty()) { if (stack.isEmpty()) {
return stack; return stack;
} }
ItemStack remain = stack.copy();
if (ActuallyAdditions.commonCapsLoaded) { if (ActuallyAdditions.commonCapsLoaded) {
Object handler = wrapper.getSlotlessHandler(); // Object handler = wrapper.getSlotlessHandler();
// if (handler instanceof ISlotlessItemHandler) { // if (handler instanceof ISlotlessItemHandler) {
// remain = ((ISlotlessItemHandler) handler).insertItem(remain, simulate); // remain = ((ISlotlessItemHandler) handler).insertItem(remain, simulate);
// if (!ItemStack.areItemStacksEqual(remain, stack)) { // if (!ItemStack.areItemStacksEqual(remain, stack)) {
@ -229,14 +222,14 @@ public final class StackUtil {
// } // }
} }
IItemHandler handler = wrapper.getNormalHandler(); return wrapper.getNormalHandler().map(e -> {
if (handler != null) { ItemStack remain = stack.copy();
for (int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++) { for (int i = Math.max(0, slotStart); i < Math.min(slotEnd, e.getSlots()); i++) {
remain = handler.insertItem(i, remain, simulate); remain = e.insertItem(i, remain, simulate);
} }
}
return remain; return remain;
}).orElse(stack);
} }
/** /**