Code style changes, entities fixes
This commit is contained in:
parent
9d604b2d25
commit
44962e18b6
377 changed files with 5038 additions and 4914 deletions
|
@ -1,7 +1,5 @@
|
|||
package ru.betterend.blocks.entities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -21,6 +19,8 @@ import ru.betterend.registry.EndBlockEntities;
|
|||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndParticles;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockEntityHydrothermalVent extends BlockEntity {
|
||||
|
||||
private final static Vec3 POSITIVE_Y = new Vec3(0.0f, 1.0f, 0.0f);
|
||||
|
@ -39,7 +39,8 @@ public class BlockEntityHydrothermalVent extends BlockEntity {
|
|||
double z = worldPosition.getZ() + level.random.nextDouble();
|
||||
if (state.getValue(HydrothermalVentBlock.WATERLOGGED)) {
|
||||
level.addParticle(EndParticles.GEYSER_PARTICLE, x, y, z, 0, 0, 0);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
level.addParticle(ParticleTypes.BUBBLE, x, y, z, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,11 +47,11 @@ import java.util.Map;
|
|||
|
||||
public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer, RecipeHolder, StackedContentsCompatible {
|
||||
|
||||
private static final int[] TOP_SLOTS = new int[] { 0, 1 };
|
||||
private static final int[] BOTTOM_SLOTS = new int[] { 2, 3 };
|
||||
private static final int[] SIDE_SLOTS = new int[] { 1, 2 };
|
||||
private static final int[] TOP_SLOTS = new int[]{0, 1};
|
||||
private static final int[] BOTTOM_SLOTS = new int[]{2, 3};
|
||||
private static final int[] SIDE_SLOTS = new int[]{1, 2};
|
||||
private static final Map<Item, Integer> AVAILABLE_FUELS = Maps.newHashMap();
|
||||
|
||||
|
||||
private final Object2IntOpenHashMap<ResourceLocation> recipesUsed;
|
||||
protected NonNullList<ItemStack> inventory;
|
||||
protected final ContainerData propertyDelegate;
|
||||
|
@ -60,47 +60,47 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
private int smeltTime;
|
||||
private int burnTime;
|
||||
private int fuelTime;
|
||||
|
||||
|
||||
public EndStoneSmelterBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||
super(EndBlockEntities.END_STONE_SMELTER, blockPos, blockState);
|
||||
this.inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
this.recipesUsed = new Object2IntOpenHashMap<>();
|
||||
this.propertyDelegate = new ContainerData() {
|
||||
public int get(int index) {
|
||||
switch(index) {
|
||||
case 0:
|
||||
return EndStoneSmelterBlockEntity.this.burnTime;
|
||||
case 1:
|
||||
return EndStoneSmelterBlockEntity.this.fuelTime;
|
||||
case 2:
|
||||
return EndStoneSmelterBlockEntity.this.smeltTime;
|
||||
case 3:
|
||||
return EndStoneSmelterBlockEntity.this.smeltTimeTotal;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
this.propertyDelegate = new ContainerData() {
|
||||
public int get(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return EndStoneSmelterBlockEntity.this.burnTime;
|
||||
case 1:
|
||||
return EndStoneSmelterBlockEntity.this.fuelTime;
|
||||
case 2:
|
||||
return EndStoneSmelterBlockEntity.this.smeltTime;
|
||||
case 3:
|
||||
return EndStoneSmelterBlockEntity.this.smeltTimeTotal;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void set(int index, int value) {
|
||||
switch(index) {
|
||||
case 0:
|
||||
EndStoneSmelterBlockEntity.this.burnTime = value;
|
||||
break;
|
||||
case 1:
|
||||
EndStoneSmelterBlockEntity.this.fuelTime = value;
|
||||
break;
|
||||
case 2:
|
||||
EndStoneSmelterBlockEntity.this.smeltTime = value;
|
||||
break;
|
||||
case 3:
|
||||
EndStoneSmelterBlockEntity.this.smeltTimeTotal = value;
|
||||
}
|
||||
}
|
||||
public void set(int index, int value) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
EndStoneSmelterBlockEntity.this.burnTime = value;
|
||||
break;
|
||||
case 1:
|
||||
EndStoneSmelterBlockEntity.this.fuelTime = value;
|
||||
break;
|
||||
case 2:
|
||||
EndStoneSmelterBlockEntity.this.smeltTime = value;
|
||||
break;
|
||||
case 3:
|
||||
EndStoneSmelterBlockEntity.this.smeltTimeTotal = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return 4;
|
||||
}
|
||||
};
|
||||
public int getCount() {
|
||||
return 4;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private boolean isBurning() {
|
||||
|
@ -121,7 +121,8 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
return true;
|
||||
}
|
||||
itemStack = iterator.next();
|
||||
} while (itemStack.isEmpty());
|
||||
}
|
||||
while (itemStack.isEmpty());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -155,19 +156,19 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
setChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected int getSmeltTime() {
|
||||
if (level == null) return 200;
|
||||
int smeltTime = level.getRecipeManager().getRecipeFor(AlloyingRecipe.TYPE, this, level)
|
||||
.map(AlloyingRecipe::getSmeltTime).orElse(0);
|
||||
if (smeltTime == 0) {
|
||||
smeltTime = level.getRecipeManager().getRecipeFor(RecipeType.BLASTING, this, level)
|
||||
.map(BlastingRecipe::getCookingTime).orElse(200);
|
||||
.map(BlastingRecipe::getCookingTime).orElse(200);
|
||||
smeltTime /= 1.5;
|
||||
}
|
||||
return smeltTime;
|
||||
}
|
||||
|
||||
|
||||
public void dropExperience(Player player) {
|
||||
if (level == null) return;
|
||||
List<Recipe<?>> list = Lists.newArrayList();
|
||||
|
@ -177,7 +178,8 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
if (recipe instanceof AlloyingRecipe) {
|
||||
AlloyingRecipe alloying = (AlloyingRecipe) recipe;
|
||||
dropExperience(player.level, player.position(), entry.getIntValue(), alloying.getExperience());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BlastingRecipe blasting = (BlastingRecipe) recipe;
|
||||
dropExperience(player.level, player.position(), entry.getIntValue(), blasting.getExperience());
|
||||
}
|
||||
|
@ -186,7 +188,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
player.awardRecipes(list);
|
||||
recipesUsed.clear();
|
||||
}
|
||||
|
||||
|
||||
private void dropExperience(Level world, Vec3 vec3d, int count, float amount) {
|
||||
int expTotal = Mth.floor(count * amount);
|
||||
float g = Mth.frac(count * amount);
|
||||
|
@ -194,7 +196,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
expTotal++;
|
||||
}
|
||||
|
||||
while(expTotal > 0) {
|
||||
while (expTotal > 0) {
|
||||
int expVal = ExperienceOrb.getExperienceValue(expTotal);
|
||||
expTotal -= expVal;
|
||||
world.addFreshEntity(new ExperienceOrb(world, vec3d.x, vec3d.y, vec3d.z, expVal));
|
||||
|
@ -239,7 +241,8 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
if (blockEntity.smeltTime > 0) {
|
||||
blockEntity.smeltTime = Mth.clamp(blockEntity.smeltTime - 2, 0, blockEntity.smeltTimeTotal);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Recipe<?> recipe = tickLevel.getRecipeManager().getRecipeFor(AlloyingRecipe.TYPE, blockEntity, tickLevel).orElse(null);
|
||||
if (recipe == null) {
|
||||
recipe = tickLevel.getRecipeManager().getRecipeFor(RecipeType.BLASTING, blockEntity, tickLevel).orElse(null);
|
||||
|
@ -270,7 +273,8 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
blockEntity.craftRecipe(recipe);
|
||||
blockEntity.setChanged();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
blockEntity.smeltTime = 0;
|
||||
}
|
||||
}
|
||||
|
@ -281,14 +285,15 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected boolean canAcceptRecipeOutput(Recipe<?> recipe) {
|
||||
if (recipe == null) return false;
|
||||
boolean validInput;
|
||||
if (recipe instanceof AlloyingRecipe) {
|
||||
validInput = !inventory.get(0).isEmpty() &&
|
||||
!inventory.get(1).isEmpty();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
validInput = !inventory.get(0).isEmpty() ||
|
||||
!inventory.get(1).isEmpty();
|
||||
}
|
||||
|
@ -316,12 +321,13 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
|
||||
private void craftRecipe(Recipe<?> recipe) {
|
||||
if (recipe == null || !canAcceptRecipeOutput(recipe)) return;
|
||||
|
||||
|
||||
ItemStack result = recipe.getResultItem();
|
||||
ItemStack output = inventory.get(3);
|
||||
if (output.isEmpty()) {
|
||||
inventory.set(3, result.copy());
|
||||
} else if (output.getItem() == result.getItem()) {
|
||||
}
|
||||
else if (output.getItem() == result.getItem()) {
|
||||
output.grow(result.getCount());
|
||||
}
|
||||
|
||||
|
@ -329,14 +335,16 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
if (!this.level.isClientSide) {
|
||||
setRecipeUsed(recipe);
|
||||
}
|
||||
|
||||
|
||||
if (recipe instanceof AlloyingRecipe) {
|
||||
inventory.get(0).shrink(1);
|
||||
inventory.get(1).shrink(1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!inventory.get(0).isEmpty()) {
|
||||
inventory.get(0).shrink(1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
inventory.get(1).shrink(1);
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +399,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
Item item = fuel.getItem();
|
||||
return AVAILABLE_FUELS.getOrDefault(item, getFabricFuel(fuel));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag tag) {
|
||||
super.load(tag);
|
||||
|
@ -406,7 +414,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
recipesUsed.put(new ResourceLocation(id), compoundTag.getInt(id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CompoundTag save(CompoundTag tag) {
|
||||
super.save(tag);
|
||||
|
@ -418,14 +426,15 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
CompoundTag usedRecipes = new CompoundTag();
|
||||
recipesUsed.forEach((identifier, integer) -> usedRecipes.putInt(identifier.toString(), integer));
|
||||
tag.put("RecipesUsed", usedRecipes);
|
||||
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
public boolean canPlaceItem(int slot, ItemStack stack) {
|
||||
if (slot == 3) {
|
||||
return false;
|
||||
} else if (slot != 2) {
|
||||
}
|
||||
else if (slot != 2) {
|
||||
return true;
|
||||
}
|
||||
ItemStack itemStack = this.inventory.get(2);
|
||||
|
@ -443,7 +452,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
|
|||
public static Map<Item, Integer> availableFuels() {
|
||||
return AVAILABLE_FUELS;
|
||||
}
|
||||
|
||||
|
||||
private static int getFabricFuel(ItemStack stack) {
|
||||
Integer ticks = FuelRegistry.INSTANCE.get(stack.getItem());
|
||||
return ticks == null ? 0 : ticks;
|
||||
|
|
|
@ -9,30 +9,30 @@ import ru.betterend.rituals.EternalRitual;
|
|||
|
||||
public class EternalPedestalEntity extends PedestalBlockEntity {
|
||||
private EternalRitual linkedRitual;
|
||||
|
||||
|
||||
public EternalPedestalEntity(BlockPos blockPos, BlockState blockState) {
|
||||
super(EndBlockEntities.ETERNAL_PEDESTAL, blockPos, blockState);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasRitual() {
|
||||
return linkedRitual != null;
|
||||
}
|
||||
|
||||
|
||||
public void linkRitual(EternalRitual ritual) {
|
||||
this.linkedRitual = ritual;
|
||||
}
|
||||
|
||||
|
||||
public EternalRitual getRitual() {
|
||||
return linkedRitual;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setLevel(Level world) {
|
||||
if (hasRitual()) {
|
||||
linkedRitual.setWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setLevelAndPosition(Level world, BlockPos pos) {
|
||||
if (hasRitual()) {
|
||||
linkedRitual.setWorld(world);
|
||||
|
|
|
@ -10,37 +10,39 @@ import ru.betterend.rituals.InfusionRitual;
|
|||
public class InfusionPedestalEntity extends PedestalBlockEntity {
|
||||
|
||||
private InfusionRitual linkedRitual;
|
||||
|
||||
|
||||
public InfusionPedestalEntity(BlockPos blockPos, BlockState blockState) {
|
||||
super(EndBlockEntities.INFUSION_PEDESTAL, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevel(Level world){
|
||||
public void setLevel(Level world) {
|
||||
super.setLevel(world);
|
||||
if (hasRitual()) {
|
||||
linkedRitual.setLocation(world, this.getBlockPos());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
linkRitual(new InfusionRitual(this, world, this.getBlockPos()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setLevelAndPosition(Level world, BlockPos pos) {
|
||||
if (hasRitual()) {
|
||||
linkedRitual.setLocation(world, pos);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
linkRitual(new InfusionRitual(this, world, pos));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void linkRitual(InfusionRitual ritual) {
|
||||
linkedRitual = ritual;
|
||||
}
|
||||
|
||||
|
||||
public InfusionRitual getRitual() {
|
||||
return linkedRitual;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasRitual() {
|
||||
return linkedRitual != null;
|
||||
}
|
||||
|
|
|
@ -16,22 +16,22 @@ import ru.betterend.registry.EndItems;
|
|||
|
||||
public class PedestalBlockEntity extends BlockEntity implements Container, BlockEntityClientSerializable {
|
||||
private ItemStack activeItem = ItemStack.EMPTY;
|
||||
|
||||
|
||||
private final int maxAge = 314;
|
||||
private int age;
|
||||
|
||||
public PedestalBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||
this(EndBlockEntities.PEDESTAL, blockPos, blockState);
|
||||
}
|
||||
|
||||
|
||||
public PedestalBlockEntity(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
|
||||
super(blockEntityType, blockPos, blockState);
|
||||
}
|
||||
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxAge() {
|
||||
return maxAge;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class PedestalBlockEntity extends BlockEntity implements Container, Block
|
|||
public ItemStack removeItem(int slot, int amount) {
|
||||
return removeItemNoUpdate(slot);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canPlaceItem(int slot, ItemStack stack) {
|
||||
return isEmpty();
|
||||
|
@ -79,7 +79,7 @@ public class PedestalBlockEntity extends BlockEntity implements Container, Block
|
|||
activeItem = stack.split(1);
|
||||
setChanged();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setChanged() {
|
||||
if (level != null && !level.isClientSide) {
|
||||
|
@ -88,7 +88,8 @@ public class PedestalBlockEntity extends BlockEntity implements Container, Block
|
|||
BlockState trueState = state.setValue(PedestalBlock.HAS_ITEM, !isEmpty());
|
||||
if (activeItem.getItem() == EndItems.ETERNAL_CRYSTAL) {
|
||||
trueState = trueState.setValue(PedestalBlock.HAS_LIGHT, true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
trueState = trueState.setValue(PedestalBlock.HAS_LIGHT, false);
|
||||
}
|
||||
level.setBlockAndUpdate(worldPosition, trueState);
|
||||
|
@ -97,12 +98,12 @@ public class PedestalBlockEntity extends BlockEntity implements Container, Block
|
|||
super.setChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag tag) {
|
||||
super.load(tag);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue