Remove the item distributor on here as well

This commit is contained in:
Ellpeck 2016-12-22 21:36:35 +01:00
parent a5e4be2d3e
commit 4724187cf0
8 changed files with 5 additions and 231 deletions

View file

@ -1,70 +0,0 @@
/*
* This file ("BlockDistributorItem.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDistributorItem;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
public class BlockDistributorItem extends BlockContainerBase implements IHudDisplay{
public BlockDistributorItem(String name){
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.75F);
this.setResistance(10.0F);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta){
return new TileEntityDistributorItem();
}
@Override
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
if(tile instanceof TileEntityDistributorItem){
TileEntityDistributorItem distributor = (TileEntityDistributorItem)tile;
ItemStack slot = distributor.slots.getStackInSlot(0);
String strg;
if(!StackUtil.isValid(slot)){
strg = StringUtil.localize("info."+ModUtil.MOD_ID+".noItem");
}
else{
strg = slot.getItem().getItemStackDisplayName(slot);
AssetUtil.renderStackToGui(slot, resolution.getScaledWidth()/2+15, resolution.getScaledHeight()/2-19, 1F);
}
minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg, resolution.getScaledWidth()/2+35, resolution.getScaledHeight()/2-15, StringUtil.DECIMAL_COLOR_WHITE);
}
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.UNCOMMON;
}
}

View file

@ -105,7 +105,6 @@ public final class InitBlocks{
public static Block blockDisplayStand; public static Block blockDisplayStand;
public static Block blockShockSuppressor; public static Block blockShockSuppressor;
public static Block blockEmpowerer; public static Block blockEmpowerer;
public static Block blockDistributorItem;
public static Block blockBioReactor; public static Block blockBioReactor;
public static Block blockTinyTorch; public static Block blockTinyTorch;
public static Block blockFarmer; public static Block blockFarmer;
@ -118,7 +117,6 @@ public final class InitBlocks{
blockItemViewerHopping = new BlockItemViewerHopping("block_item_viewer_hopping"); blockItemViewerHopping = new BlockItemViewerHopping("block_item_viewer_hopping");
blockFarmer = new BlockFarmer("block_farmer"); blockFarmer = new BlockFarmer("block_farmer");
blockBioReactor = new BlockBioReactor("block_bio_reactor"); blockBioReactor = new BlockBioReactor("block_bio_reactor");
blockDistributorItem = new BlockDistributorItem("block_distributor_item");
blockEmpowerer = new BlockEmpowerer("block_empowerer"); blockEmpowerer = new BlockEmpowerer("block_empowerer");
blockTinyTorch = new BlockTinyTorch("block_tiny_torch"); blockTinyTorch = new BlockTinyTorch("block_tiny_torch");
blockShockSuppressor = new BlockShockSuppressor("block_shock_suppressor"); blockShockSuppressor = new BlockShockSuppressor("block_shock_suppressor");

View file

@ -202,7 +202,6 @@ public final class InitBooklet{
new BookletChapter("phantomRedstoneface", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockPhantomRedstoneface), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipePhantomRedstoneface).setNoText()); new BookletChapter("phantomRedstoneface", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockPhantomRedstoneface), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipePhantomRedstoneface).setNoText());
new BookletChapter("phantomBreaker", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockPhantomBreaker), new PageTextOnly(1).addTextReplacement("<range>", TileEntityPhantomPlacer.RANGE), new PageCrafting(2, BlockCrafting.recipePhantomPlacer).setNoText(), new PageCrafting(3, BlockCrafting.recipePhantomBreaker).setNoText()); new BookletChapter("phantomBreaker", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockPhantomBreaker), new PageTextOnly(1).addTextReplacement("<range>", TileEntityPhantomPlacer.RANGE), new PageCrafting(2, BlockCrafting.recipePhantomPlacer).setNoText(), new PageCrafting(3, BlockCrafting.recipePhantomBreaker).setNoText());
new BookletChapter("esd", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockInputterAdvanced), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeESD).setNoText(), new PageCrafting(3, BlockCrafting.recipeAdvancedESD).setNoText()).setSpecial(); new BookletChapter("esd", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockInputterAdvanced), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeESD).setNoText(), new PageCrafting(3, BlockCrafting.recipeAdvancedESD).setNoText()).setSpecial();
new BookletChapter("distributorItem", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockDistributorItem), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeDistributorItem).setNoText()).setSpecial();
new BookletChapter("xpSolidifier", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockXPSolidifier), new PageTextOnly(1).addItemToPage(new ItemStack(InitItems.itemSolidifiedExperience)), new PageCrafting(2, BlockCrafting.recipeSolidifier).setNoText()).setImportant(); new BookletChapter("xpSolidifier", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockXPSolidifier), new PageTextOnly(1).addItemToPage(new ItemStack(InitItems.itemSolidifiedExperience)), new PageCrafting(2, BlockCrafting.recipeSolidifier).setNoText()).setImportant();
new BookletChapter("greenhouseGlass", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockGreenhouseGlass), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeGlass)); new BookletChapter("greenhouseGlass", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockGreenhouseGlass), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeGlass));
new BookletChapter("fishingNet", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockFishingNet), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFisher).setNoText()); new BookletChapter("fishingNet", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockFishingNet), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFisher).setNoText());

View file

@ -94,7 +94,6 @@ public final class BlockCrafting{
public static IRecipe recipeShockSuppressor; public static IRecipe recipeShockSuppressor;
public static IRecipe recipeEmpowerer; public static IRecipe recipeEmpowerer;
public static IRecipe[] recipesTinyTorch = new IRecipe[2]; public static IRecipe[] recipesTinyTorch = new IRecipe[2];
public static IRecipe recipeDistributorItem;
public static IRecipe recipeBioReactor; public static IRecipe recipeBioReactor;
public static IRecipe recipeFarmer; public static IRecipe recipeFarmer;
public static IRecipe recipeBatteryBox; public static IRecipe recipeBatteryBox;
@ -147,14 +146,6 @@ public final class BlockCrafting{
'C', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()))); 'C', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal())));
recipeFireworkBox = RecipeUtil.lastIRecipe(); recipeFireworkBox = RecipeUtil.lastIRecipe();
//Item Distributor
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockDistributorItem),
"WHW", "HCH", "WHW",
'W', "plankWood",
'H', new ItemStack(Blocks.HOPPER),
'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal())));
recipeDistributorItem = RecipeUtil.lastIRecipe();
//Shock Suppressor //Shock Suppressor
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockShockSuppressor), GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockShockSuppressor),
"OAO", "ACA", "OAO", "OAO", "ACA", "OAO",

View file

@ -82,7 +82,6 @@ public class CreativeTab extends CreativeTabs{
this.add(InitBlocks.blockCoffeeMachine); this.add(InitBlocks.blockCoffeeMachine);
this.add(InitBlocks.blockXPSolidifier); this.add(InitBlocks.blockXPSolidifier);
this.add(InitBlocks.blockDisplayStand); this.add(InitBlocks.blockDisplayStand);
this.add(InitBlocks.blockDistributorItem);
this.add(InitBlocks.blockFarmer); this.add(InitBlocks.blockFarmer);
this.add(InitBlocks.blockShockSuppressor); this.add(InitBlocks.blockShockSuppressor);

View file

@ -114,7 +114,6 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
register(TileEntityShockSuppressor.class); register(TileEntityShockSuppressor.class);
register(TileEntityEmpowerer.class); register(TileEntityEmpowerer.class);
register(TileEntityLaserRelayFluids.class); register(TileEntityLaserRelayFluids.class);
register(TileEntityDistributorItem.class);
register(TileEntityBioReactor.class); register(TileEntityBioReactor.class);
register(TileEntityFarmer.class); register(TileEntityFarmer.class);
register(TileEntityItemViewerHopping.class); register(TileEntityItemViewerHopping.class);

View file

@ -1,143 +0,0 @@
/*
* This file ("TileEntityDistributorItem.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import java.util.HashMap;
import java.util.Map;
public class TileEntityDistributorItem extends TileEntityInventoryBase{
private final Map<EnumFacing, IItemHandler> handlersAround = new HashMap<EnumFacing, IItemHandler>();
private int putSide;
public TileEntityDistributorItem(){
super(1, "distributorItem");
}
@Override
public void updateEntity(){
super.updateEntity();
if(!this.world.isRemote){
boolean shouldMarkDirty = false;
IItemHandler handlerUp = this.handlersAround.get(EnumFacing.UP);
if(handlerUp != null){
for(int i = 0; i < handlerUp.getSlots(); i++){
ItemStack pullable = handlerUp.extractItem(i, 1, true);
if(StackUtil.isValid(pullable) && (!StackUtil.isValid(this.slots.getStackInSlot(0)) || (ItemUtil.canBeStacked(this.slots.getStackInSlot(0), pullable) && StackUtil.getStackSize(this.slots.getStackInSlot(0)) < this.slots.getStackInSlot(0).getMaxStackSize()))){
ItemStack pulled = handlerUp.extractItem(i, 1, false);
if(StackUtil.isValid(pulled)){
if(!StackUtil.isValid(this.slots.getStackInSlot(0))){
this.slots.setStackInSlot(0, pulled.copy());
}
else{
this.slots.setStackInSlot(0, StackUtil.addStackSize(this.slots.getStackInSlot(0), StackUtil.getStackSize(pulled)));
}
shouldMarkDirty = true;
break;
}
}
if(StackUtil.isValid(this.slots.getStackInSlot(0)) && StackUtil.getStackSize(this.slots.getStackInSlot(0)) >= this.slots.getStackInSlot(0).getMaxStackSize()){
break;
}
}
}
if(!this.handlersAround.isEmpty() && (!this.handlersAround.containsKey(EnumFacing.UP) || this.handlersAround.size() >= 2) && StackUtil.isValid(this.slots.getStackInSlot(0))){
EnumFacing[] allFacings = EnumFacing.values();
do{
this.putSide++;
if(this.putSide >= 6){
this.putSide = 0;
}
}
while(allFacings[this.putSide] == EnumFacing.UP || !this.handlersAround.containsKey(allFacings[this.putSide]));
EnumFacing putFacing = allFacings[this.putSide];
IItemHandler handler = this.handlersAround.get(putFacing);
if(handler != null){
int aroundAmount = this.handlersAround.containsKey(EnumFacing.UP) ? this.handlersAround.size()-1 : this.handlersAround.size();
int amount = StackUtil.getStackSize(this.slots.getStackInSlot(0))/aroundAmount;
if(amount <= 0){
amount = StackUtil.getStackSize(this.slots.getStackInSlot(0));
}
if(amount > 0){
ItemStack toInsert = this.slots.getStackInSlot(0).copy();
toInsert = StackUtil.setStackSize(toInsert, amount);
for(int i = 0; i < handler.getSlots(); i++){
toInsert = handler.insertItem(i, toInsert.copy(), false);
if(!StackUtil.isValid(toInsert)){
this.slots.setStackInSlot(0, StackUtil.addStackSize(this.slots.getStackInSlot(0), -amount));
shouldMarkDirty = true;
break;
}
}
}
}
}
if(shouldMarkDirty){
this.markDirty();
}
}
}
@Override
public void saveDataOnChangeOrWorldStart(){
this.handlersAround.clear();
for(EnumFacing side : EnumFacing.values()){
TileEntity tile = this.world.getTileEntity(this.pos.offset(side));
if(tile != null && tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite())){
IItemHandler cap = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite());
if(cap != null){
this.handlersAround.put(side, cap);
}
}
}
}
@Override
public boolean shouldSyncSlots(){
return true;
}
@Override
public boolean shouldSaveDataOnChangeOrWorldStart(){
return true;
}
@Override
public boolean canExtractItem(int index, ItemStack stack){
return true;
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack){
return true;
}
}

View file

@ -25,10 +25,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent; import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
//TODO Remove the whole registry name mapping thing once the 1.11 fading phase is over //TODO Remove the whole registry name mapping thing once the 1.11 fading phase is over
@ -80,6 +77,10 @@ public final class ItemUtil{
public static boolean remapName(FMLMissingMappingsEvent.MissingMapping mapping){ public static boolean remapName(FMLMissingMappingsEvent.MissingMapping mapping){
if(mapping != null && mapping.name != null){ if(mapping != null && mapping.name != null){
if(mapping.name.toLowerCase(Locale.ROOT).contains("distributor")){
return true;
}
if(UNDERSCORELESS_TO_UNDERSCORED_NAMES.containsKey(mapping.name)){ if(UNDERSCORELESS_TO_UNDERSCORED_NAMES.containsKey(mapping.name)){
String newName = UNDERSCORELESS_TO_UNDERSCORED_NAMES.get(mapping.name); String newName = UNDERSCORELESS_TO_UNDERSCORED_NAMES.get(mapping.name);
ResourceLocation newResLoc = new ResourceLocation(newName); ResourceLocation newResLoc = new ResourceLocation(newName);