Finish making some quality of life changes
This commit is contained in:
parent
8a395bd9d6
commit
30bbd059b3
63 changed files with 1256 additions and 908 deletions
|
@ -20,8 +20,10 @@ import dev.zontreck.otemod.implementation.CreativeModeTabs;
|
|||
import dev.zontreck.otemod.implementation.InventoryBackup;
|
||||
import dev.zontreck.otemod.implementation.Messages;
|
||||
import dev.zontreck.otemod.implementation.PlayerFirstJoinTag;
|
||||
import dev.zontreck.otemod.implementation.compressor.CompressionChamberScreen;
|
||||
import dev.zontreck.otemod.implementation.vault.*;
|
||||
import dev.zontreck.otemod.integrations.KeyBindings;
|
||||
import dev.zontreck.otemod.recipe.ModRecipes;
|
||||
import net.minecraft.client.gui.screens.MenuScreens;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -130,6 +132,7 @@ public class OTEMod
|
|||
ModEntities.register(bus);
|
||||
ModEnchantments.register(bus);
|
||||
ModEntityTypes.register(bus);
|
||||
ModRecipes.register(bus);
|
||||
|
||||
|
||||
//MenuInitializer.register(bus);
|
||||
|
@ -312,6 +315,7 @@ public class OTEMod
|
|||
MenuScreens.register(ModMenuTypes.VAULT.get(), VaultScreen::new);
|
||||
MenuScreens.register(ModMenuTypes.SCRUBBER.get(), ItemScrubberScreen::new);
|
||||
MenuScreens.register(ModMenuTypes.MAGIC_SCRUBBER.get(), MagicalScrubberScreen::new);
|
||||
MenuScreens.register(ModMenuTypes.COMPRESSION_CHAMBER.get(), CompressionChamberScreen::new);
|
||||
|
||||
//ItemBlockRenderTypes.setRenderLayer(ModBlocks.AURORA_DOOR.get(), RenderType.translucent());
|
||||
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
package dev.zontreck.otemod.blocks;
|
||||
|
||||
import dev.zontreck.otemod.blocks.entity.CompressionChamberBlockEntity;
|
||||
import dev.zontreck.otemod.blocks.entity.ModEntities;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CompressionChamberBlock extends BaseEntityBlock
|
||||
{
|
||||
|
||||
public CompressionChamberBlock(Properties pProperties) {
|
||||
super(pProperties);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||
return new CompressionChamberBlockEntity(blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState pState) {
|
||||
return RenderShape.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level lvl, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit)
|
||||
{
|
||||
if(!lvl.isClientSide())
|
||||
{
|
||||
BlockEntity be = lvl.getBlockEntity(pos);
|
||||
if(be instanceof CompressionChamberBlockEntity)
|
||||
{
|
||||
CompressionChamberBlockEntity entity = (CompressionChamberBlockEntity) be;
|
||||
NetworkHooks.openScreen(((ServerPlayer)player), entity, pos);
|
||||
|
||||
ModMessages.sendToPlayer(new EnergySyncS2CPacket(entity.getEnergyStorage().getEnergyStored(), entity.getBlockPos()), (ServerPlayer)player);
|
||||
|
||||
}else{
|
||||
throw new IllegalStateException("Our container is missing!");
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.sidedSuccess(lvl.isClientSide);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pMovedByPiston) {
|
||||
if(pState.getBlock() != pNewState.getBlock())
|
||||
{
|
||||
BlockEntity be = pLevel.getBlockEntity(pPos);
|
||||
if(be instanceof CompressionChamberBlockEntity)
|
||||
{
|
||||
((CompressionChamberBlockEntity)be).doDrop();
|
||||
}
|
||||
}
|
||||
|
||||
super.onRemove(pState, pLevel, pPos, pNewState, pMovedByPiston);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level pLevel, BlockState pState, BlockEntityType<T> pBlockEntityType) {
|
||||
|
||||
return createTickerHelper(pBlockEntityType, ModEntities.COMPRESSION_CHAMBER.get(), CompressionChamberBlockEntity::tick);
|
||||
}
|
||||
}
|
|
@ -90,6 +90,18 @@ public class ModBlocks {
|
|||
|
||||
public static final RegistryObject<Item> ILUSIUM_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("ilusium_block", () -> new BlockItem(ILUSIUM_BLOCK.get(), new Item.Properties())));
|
||||
|
||||
public static final RegistryObject<Block> COMPRESSION_CHAMBER_BLOCK = BLOCKS.register("compression_chamber", ()->new CompressionChamberBlock(BlockBehaviour.Properties.copy(ModBlocks.ILUSIUM_BLOCK.get()).noOcclusion().isViewBlocking(ModBlocks::never)));
|
||||
|
||||
public static final RegistryObject<Item> COMPRESSION_CHAMBER_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("compression_chamber", ()->new BlockItem(COMPRESSION_CHAMBER_BLOCK.get(), new Item.Properties())));
|
||||
|
||||
|
||||
public static final RegistryObject<Block> COMPRESSED_OBSIDIAN_BLOCK = BLOCKS.register("compressed_obsidian_block", ()->new Block(BlockBehaviour.Properties.copy(Blocks.OBSIDIAN)));
|
||||
|
||||
public static final RegistryObject<Item> COMPRESSED_OBSIDIAN_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("compressed_obsidian_block", ()->new BlockItem(COMPRESSED_OBSIDIAN_BLOCK.get(), new Item.Properties())));
|
||||
public static final RegistryObject<Block> LAYERED_COMPRESSED_OBSIDIAN_BLOCK = BLOCKS.register("layered_compressed_obsidian_block", ()->new Block(BlockBehaviour.Properties.copy(Blocks.OBSIDIAN)));
|
||||
|
||||
public static final RegistryObject<Item> LAYERED_COMPRESSED_OBSIDIAN_BLOCK_I = CreativeModeTabs.addToOTEModTab(ITEMS.register("layered_compressed_obsidian_block", ()->new BlockItem(LAYERED_COMPRESSED_OBSIDIAN_BLOCK.get(), new Item.Properties())));
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,305 @@
|
|||
package dev.zontreck.otemod.blocks.entity;
|
||||
|
||||
import dev.zontreck.otemod.implementation.OutputItemStackHandler;
|
||||
import dev.zontreck.otemod.implementation.compressor.CompressionChamberMenu;
|
||||
import dev.zontreck.otemod.implementation.energy.OTEEnergy;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||
import dev.zontreck.otemod.recipe.CompressionChamberRecipe;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.ContainerData;
|
||||
import net.minecraft.world.inventory.SimpleContainerData;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.EnergyStorage;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
public class CompressionChamberBlockEntity extends BlockEntity implements MenuProvider
|
||||
{
|
||||
|
||||
public CompressionChamberBlockEntity(BlockPos pPos, BlockState pBlockState) {
|
||||
super(ModEntities.COMPRESSION_CHAMBER.get(), pPos, pBlockState);
|
||||
|
||||
outputSlot = new OutputItemStackHandler(outputItems);
|
||||
data = new ContainerData() {
|
||||
@Override
|
||||
public int get(int i) {
|
||||
return switch (i){
|
||||
case 0 -> CompressionChamberBlockEntity.this.progress;
|
||||
default -> 0;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int i, int i1) {
|
||||
switch(i)
|
||||
{
|
||||
case 0->CompressionChamberBlockEntity.this.progress = i1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected final ContainerData data;
|
||||
protected int progress=0;
|
||||
|
||||
public static final int MAXIMUM_PROCESSING_TICKS = 750;
|
||||
|
||||
protected final ItemStackHandler itemsHandler = new ItemStackHandler(1){
|
||||
@Override
|
||||
protected void onContentsChanged(int slot)
|
||||
{
|
||||
setChanged();
|
||||
}
|
||||
};
|
||||
protected final ItemStackHandler outputItems = new ItemStackHandler(1){
|
||||
@Override
|
||||
protected void onContentsChanged(int slot)
|
||||
{
|
||||
setChanged();
|
||||
}
|
||||
};
|
||||
private ItemStackHandler outputSlot;
|
||||
|
||||
private final OTEEnergy ENERGY_STORAGE = new OTEEnergy(ENERGY_REQUIREMENT*3, ENERGY_REQUIREMENT*512) {
|
||||
|
||||
@Override
|
||||
public void onChanged() {
|
||||
setChanged();
|
||||
|
||||
ModMessages.sendToAll(new EnergySyncS2CPacket(energy, getBlockPos()));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private static final int ENERGY_REQUIREMENT = 7500;
|
||||
|
||||
private LazyOptional<IEnergyStorage> lazyEnergyHandler = LazyOptional.empty();
|
||||
|
||||
private LazyOptional<IItemHandler> lazyItemHandler = LazyOptional.empty();
|
||||
private LazyOptional<IItemHandler> lazyOutputItems = LazyOptional.empty();
|
||||
|
||||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.literal("Compression Chamber");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public AbstractContainerMenu createMenu(int id, Inventory inv, Player player) {
|
||||
return new CompressionChamberMenu(id, inv, this, this.data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side)
|
||||
{
|
||||
if(cap == ForgeCapabilities.ENERGY)
|
||||
{
|
||||
return lazyEnergyHandler.cast();
|
||||
}
|
||||
if(side == Direction.DOWN && cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
{
|
||||
// Return the output slot only
|
||||
return lazyOutputItems.cast();
|
||||
}
|
||||
if(cap == ForgeCapabilities.ITEM_HANDLER)
|
||||
{
|
||||
return lazyItemHandler.cast();
|
||||
}
|
||||
|
||||
return super.getCapability(cap,side);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
super.onLoad();
|
||||
lazyItemHandler = LazyOptional.of(()->itemsHandler);
|
||||
lazyOutputItems = LazyOptional.of(()->outputSlot);
|
||||
lazyEnergyHandler = LazyOptional.of(()->ENERGY_STORAGE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void invalidateCaps()
|
||||
{
|
||||
super.invalidateCaps();
|
||||
lazyItemHandler.invalidate();
|
||||
lazyOutputItems.invalidate();
|
||||
lazyEnergyHandler.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveAdditional(CompoundTag nbt)
|
||||
{
|
||||
nbt.put("inventory", itemsHandler.serializeNBT());
|
||||
nbt.put("output", outputItems.serializeNBT());
|
||||
nbt.putInt("prog", progress);
|
||||
nbt.putInt("energy", ENERGY_STORAGE.getEnergyStored());
|
||||
|
||||
super.saveAdditional(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag nbt){
|
||||
super.load(nbt);
|
||||
|
||||
itemsHandler.deserializeNBT(nbt.getCompound("inventory"));
|
||||
outputItems.deserializeNBT(nbt.getCompound("output"));
|
||||
progress = nbt.getInt("prog");
|
||||
ENERGY_STORAGE.setEnergy(nbt.getInt("energy"));
|
||||
}
|
||||
|
||||
public void doDrop()
|
||||
{
|
||||
SimpleContainer cont = new SimpleContainer(itemsHandler.getSlots());
|
||||
for (int i = 0; i < itemsHandler.getSlots(); i++) {
|
||||
cont.setItem(i, itemsHandler.getStackInSlot(i));
|
||||
}
|
||||
cont = new SimpleContainer(outputItems.getSlots());
|
||||
for (int i = 0; i < outputItems.getSlots(); i++) {
|
||||
cont.setItem(i, outputItems.getStackInSlot(i));
|
||||
}
|
||||
|
||||
Containers.dropContents(this.level, this.worldPosition, cont);
|
||||
}
|
||||
|
||||
|
||||
public static void tick(Level lvl, BlockPos pos, BlockState state, CompressionChamberBlockEntity entity)
|
||||
{
|
||||
if(lvl.isClientSide())return;
|
||||
|
||||
|
||||
if(hasRecipe(entity))
|
||||
{
|
||||
if(!hasEnergy(entity))return; // Halt until sufficient energy has been received
|
||||
entity.progress++;
|
||||
setChanged(lvl, pos, state);
|
||||
drain(entity);
|
||||
|
||||
if(entity.progress >= CompressionChamberBlockEntity.MAXIMUM_PROCESSING_TICKS)
|
||||
{
|
||||
craftItem(entity);
|
||||
}
|
||||
}else {
|
||||
if(entity.progress>0){
|
||||
entity.resetProgress();
|
||||
setChanged(lvl, pos, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void drain(CompressionChamberBlockEntity entity) {
|
||||
entity.ENERGY_STORAGE.extractEnergy(ENERGY_REQUIREMENT, false);
|
||||
}
|
||||
|
||||
private static boolean hasEnergy(CompressionChamberBlockEntity entity) {
|
||||
return (entity.ENERGY_STORAGE.getEnergyStored() >= ENERGY_REQUIREMENT);
|
||||
}
|
||||
|
||||
|
||||
private static void craftItem(CompressionChamberBlockEntity entity) {
|
||||
if(hasRecipe(entity))
|
||||
{
|
||||
SimpleContainer inventory = new SimpleContainer(entity.itemsHandler.getSlots());
|
||||
for(int i=0;i<entity.itemsHandler.getSlots();i++)
|
||||
{
|
||||
inventory.setItem(i, entity.itemsHandler.getStackInSlot(i));
|
||||
}
|
||||
SimpleContainer output = new SimpleContainer(entity.outputItems.getSlots());
|
||||
for(int i=0;i<entity.outputItems.getSlots();i++)
|
||||
{
|
||||
output.setItem(i, entity.outputItems.getStackInSlot(i));
|
||||
}
|
||||
|
||||
Optional<CompressionChamberRecipe> recipe = entity.level.getRecipeManager().getRecipeFor(CompressionChamberRecipe.Type.INSTANCE, inventory, entity.level);
|
||||
|
||||
ItemStack existing = entity.outputItems.getStackInSlot(0);
|
||||
|
||||
if(existing.is(Items.AIR))
|
||||
{
|
||||
existing = recipe.get().getResultItem(entity.level.registryAccess());
|
||||
}else
|
||||
existing.setCount(recipe.get().getResultItem(entity.level.registryAccess()).getCount() + existing.getCount());
|
||||
|
||||
entity.outputItems.setStackInSlot(0, existing);
|
||||
entity.itemsHandler.extractItem(0,1,false);
|
||||
|
||||
|
||||
entity.resetProgress();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasRecipe(CompressionChamberBlockEntity entity) {
|
||||
SimpleContainer inventory = new SimpleContainer(entity.itemsHandler.getSlots());
|
||||
for(int i=0;i<entity.itemsHandler.getSlots();i++)
|
||||
{
|
||||
inventory.setItem(i, entity.itemsHandler.getStackInSlot(i));
|
||||
}
|
||||
SimpleContainer output = new SimpleContainer(entity.outputItems.getSlots());
|
||||
for(int i=0;i<entity.outputItems.getSlots();i++)
|
||||
{
|
||||
output.setItem(i, entity.outputItems.getStackInSlot(i));
|
||||
}
|
||||
|
||||
Optional<CompressionChamberRecipe> recipe = entity.level.getRecipeManager().getRecipeFor(CompressionChamberRecipe.Type.INSTANCE, inventory, entity.level);
|
||||
|
||||
return recipe.isPresent() && canInsertIntoOutput(output, recipe.get().getResultItem(entity.level.registryAccess()));
|
||||
}
|
||||
|
||||
private static boolean canInsertIntoOutput(SimpleContainer inventory, ItemStack result) {
|
||||
ItemStack existing = inventory.getItem(0);
|
||||
boolean stackCompat = (existing.getMaxStackSize() > existing.getCount());
|
||||
boolean sameType = (existing.getItem() == result.getItem());
|
||||
boolean outputEmpty = existing.isEmpty();
|
||||
|
||||
if(outputEmpty)return true;
|
||||
return (stackCompat && sameType);
|
||||
}
|
||||
|
||||
private void resetProgress() {
|
||||
progress=0;
|
||||
|
||||
}
|
||||
|
||||
public IEnergyStorage getEnergyStorage() {
|
||||
return ENERGY_STORAGE;
|
||||
}
|
||||
|
||||
public void setEnergy(int energy) {
|
||||
ENERGY_STORAGE.setEnergy(energy);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package dev.zontreck.otemod.blocks.entity;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.blocks.CompressionChamberBlock;
|
||||
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
@ -19,6 +20,8 @@ public class ModEntities {
|
|||
|
||||
public static final ResourceLocation PARALLAX_BLOCK = new ResourceLocation(OTEMod.MOD_ID, "parallax_block");
|
||||
|
||||
public static final RegistryObject<BlockEntityType<CompressionChamberBlockEntity>> COMPRESSION_CHAMBER = ENTITIES.register("compression_chamber", ()->BlockEntityType.Builder.of(CompressionChamberBlockEntity::new, ModBlocks.COMPRESSION_CHAMBER_BLOCK.get()).build(null));
|
||||
|
||||
public static final RegistryObject <BlockEntityType <ParallaxWindowEntity>> PARALLAX_WINDOW_ENTITY = ENTITIES.register("parallax_window", ()->BlockEntityType.Builder.of(ParallaxWindowEntity::new, ModBlocks.LIMINAL_WINDOW.get()).build(null));
|
||||
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ public class OTEServerConfig {
|
|||
|
||||
public static final ForgeConfigSpec.ConfigValue<Boolean> GIVE_KIT_EVERY_CHANGE;
|
||||
|
||||
public static final ForgeConfigSpec.ConfigValue<Boolean> DEBUG;
|
||||
|
||||
static {
|
||||
List<String> defaultExcludeDimensions = new ArrayList<String>();
|
||||
|
@ -44,6 +45,7 @@ public class OTEServerConfig {
|
|||
defaultExcludeDimensions.add("minecraft:the_end"); // Excluded due to End Crystals
|
||||
|
||||
BUILDER.push("OTE");
|
||||
DEBUG = BUILDER.comment("Turn on debug messages in the console for all OTE functions? This could be spammy").define("debug_enabled", false);
|
||||
|
||||
BUILDER.push("STARTERKIT");
|
||||
GIVE_KIT_EVERY_CHANGE = BUILDER.comment("Enable this to give the starter kit every time it is changed, regardless of whether the player has already received that kit on their next join.").define("starter_kit_given_on_change", false);
|
||||
|
@ -79,7 +81,6 @@ public class OTEServerConfig {
|
|||
defDims.add("minecraft:the_end");
|
||||
defDims.add("minecraft:the_nether");
|
||||
defDims.add("otemod:resource");
|
||||
defDims.add("otemod:resource_nether");
|
||||
EXCLUDE_DIMS = BUILDER.comment("Dimension names (ex. minecraft:overworld) to exclude from the explosion healing events").define("exclude_dimensions", defDims);
|
||||
|
||||
BUILDER.pop();
|
||||
|
|
|
@ -72,6 +72,12 @@ public class FlightEnchantment extends Enchantment
|
|||
|
||||
recheck((ServerPlayer)ev.getEntity());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onArmorBreak(LivingEquipmentChangeEvent ev)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public FlightEnchantment(EquipmentSlot... slots)
|
||||
|
|
|
@ -2,6 +2,7 @@ package dev.zontreck.otemod.enchantments;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -67,6 +68,11 @@ public class MobEggEnchantment extends Enchantment
|
|||
CHANCE += bias;
|
||||
|
||||
double rng = Math.random()*100000;
|
||||
|
||||
if(OTEServerConfig.DEBUG.get())
|
||||
{
|
||||
OTEMod.LOGGER.info("Spawn Egg Chance (" + CHANCE + ") [" + rng + "]");
|
||||
}
|
||||
return (rng <= CHANCE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,20 +76,16 @@ public class EventHandler {
|
|||
double num = rng.nextDouble(0,100000);
|
||||
if(num <= base_chance)
|
||||
{
|
||||
ItemStack head = HeadUtilities.get(profile.username).setHoverName(ChatHelpers.macro(profile.nickname+"'s Head"));
|
||||
ItemStack head = HeadUtilities.get(profile.username, "").setHoverName(ChatHelpers.macro(profile.nickname+"'s Head"));
|
||||
LoreContainer lore = new LoreContainer(head);
|
||||
LoreEntry entry = new LoreEntry();
|
||||
entry.text = ChatHelpers.macroize("!dark_green!Player: " + profile.name_color+profile.username);
|
||||
entry.bold=true;
|
||||
lore.miscData.LoreData.add(entry);
|
||||
LoreEntry entry = new LoreEntry.Builder().bold(true).text(ChatHelpers.macroize("!dark_green!Player: " + profile.name_color+profile.username)).build();
|
||||
lore.miscData.loreData.add(entry);
|
||||
|
||||
entry = new LoreEntry();
|
||||
entry.text = ChatHelpers.macroize("!Dark_Purple!Date: !Dark_Red![0]", Date.from(Instant.now()).toString());
|
||||
lore.miscData.LoreData.add(entry);
|
||||
entry = new LoreEntry.Builder().text(ChatHelpers.macroize("!Dark_Purple!Date: !Dark_Red![0]", Date.from(Instant.now()).toString())).build();
|
||||
lore.miscData.loreData.add(entry);
|
||||
|
||||
entry = new LoreEntry();
|
||||
entry.text = ChatHelpers.macroize("!Dark_Purple!Total Deaths: !Dark_Red![0]", String.valueOf(profile.deaths));
|
||||
lore.miscData.LoreData.add(entry);
|
||||
entry = new LoreEntry.Builder().text(ChatHelpers.macroize("!Dark_Purple!Total Deaths: !Dark_Red![0]", String.valueOf(profile.deaths))).build();
|
||||
lore.miscData.loreData.add(entry);
|
||||
lore.commitLore();
|
||||
|
||||
|
||||
|
|
|
@ -149,13 +149,7 @@ public class LoreHandlers {
|
|||
CompoundTag props = weaponUsed.getTag();
|
||||
if(props==null)props=new CompoundTag();
|
||||
CompoundTag container = props.getCompound(ItemStatTag.STATS_TAG+"_"+type.name().toLowerCase());
|
||||
LoreContainer contain;
|
||||
if(container.isEmpty())
|
||||
{
|
||||
contain = new LoreContainer(weaponUsed);
|
||||
}else {
|
||||
contain = new LoreContainer(container, weaponUsed);
|
||||
}
|
||||
LoreContainer contain = new LoreContainer(weaponUsed);
|
||||
|
||||
ItemStatTag isTag;
|
||||
try{
|
||||
|
@ -166,26 +160,17 @@ public class LoreHandlers {
|
|||
isTag.increment();
|
||||
LoreEntry entry;
|
||||
|
||||
if(contain.miscData.LoreData.size()==0)
|
||||
if(contain.miscData.loreData.size()==0)
|
||||
{
|
||||
// Missing entry
|
||||
entry = new LoreEntry();
|
||||
entry.text = ItemStatistics.makeText(isTag);
|
||||
contain.miscData.LoreData.add(entry);
|
||||
entry = new LoreEntry.Builder().text(ItemStatistics.makeText(isTag)).build();
|
||||
contain.miscData.loreData.add(entry);
|
||||
}else {
|
||||
entry = contain.miscData.LoreData.get(0); // Stat is set at 0
|
||||
entry = contain.miscData.loreData.get(0); // Stat is set at 0
|
||||
entry.text = ItemStatistics.makeText(isTag);
|
||||
}
|
||||
|
||||
// Update item
|
||||
contain.commitLore();
|
||||
|
||||
// Save the misc data to the item for later
|
||||
// Reinitialize the container as the contain NBT
|
||||
container = new CompoundTag();
|
||||
contain.save(container);
|
||||
isTag.save(container);
|
||||
props.put(ItemStatTag.STATS_TAG+"_"+type.name().toLowerCase(), container);
|
||||
weaponUsed.setTag(props);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,158 @@
|
|||
package dev.zontreck.otemod.implementation.compressor;
|
||||
|
||||
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||
import dev.zontreck.otemod.blocks.entity.CompressionChamberBlockEntity;
|
||||
import dev.zontreck.otemod.blocks.entity.ItemScrubberBlockEntity;
|
||||
import dev.zontreck.otemod.blocks.entity.ModEntities;
|
||||
import dev.zontreck.otemod.implementation.inits.ModMenuTypes;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.*;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class CompressionChamberMenu extends AbstractContainerMenu
|
||||
{
|
||||
public final CompressionChamberBlockEntity entity;
|
||||
public final Level level;
|
||||
public final ContainerData data;
|
||||
|
||||
public CompressionChamberMenu(int id, Inventory inv, FriendlyByteBuf buf)
|
||||
{
|
||||
this(id, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(1));
|
||||
}
|
||||
|
||||
public CompressionChamberMenu(int id, Inventory inv, BlockEntity entity, ContainerData data)
|
||||
{
|
||||
super(ModMenuTypes.COMPRESSION_CHAMBER.get(), id);
|
||||
|
||||
checkContainerSize(inv, 1);
|
||||
|
||||
this.data=data;
|
||||
this.level = entity.getLevel();
|
||||
this.entity = (CompressionChamberBlockEntity) entity;
|
||||
|
||||
|
||||
addPlayerInventory(inv);
|
||||
addPlayerHotbar(inv);
|
||||
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.UP).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 34,34));
|
||||
});
|
||||
|
||||
this.entity.getCapability(ForgeCapabilities.ITEM_HANDLER, Direction.DOWN).ifPresent(handler->{
|
||||
addSlot(new SlotItemHandler(handler, 0, 113, 34));
|
||||
});
|
||||
|
||||
|
||||
addDataSlots(data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isCrafting()
|
||||
{
|
||||
return data.get(0) > 0;
|
||||
}
|
||||
|
||||
public int getScaledProgress()
|
||||
{
|
||||
if(!isCrafting())return 0;
|
||||
int progress = this.data.get(0);
|
||||
int max = CompressionChamberBlockEntity.MAXIMUM_PROCESSING_TICKS;
|
||||
|
||||
int progressArrow = 39;
|
||||
|
||||
|
||||
if(progress != 0 && max != 0)
|
||||
{
|
||||
int percent = progress * progressArrow / max;
|
||||
return percent;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons
|
||||
// must assign a slot number to each of the slots used by the GUI.
|
||||
// For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar.
|
||||
// Each time we add a Slot to the container, it automatically increases the slotIndex, which means
|
||||
// 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8)
|
||||
// 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35)
|
||||
// 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8)
|
||||
private static final int HOTBAR_SLOT_COUNT = 9;
|
||||
private static final int PLAYER_INVENTORY_ROW_COUNT = 3;
|
||||
private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
|
||||
private static final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT;
|
||||
private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;
|
||||
private static final int VANILLA_FIRST_SLOT_INDEX = 0;
|
||||
private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
|
||||
|
||||
// THIS YOU HAVE TO DEFINE!
|
||||
private static final int TE_INVENTORY_SLOT_COUNT = 2; // must be the number of slots you have!
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||
Slot sourceSlot = slots.get(index);
|
||||
if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM
|
||||
ItemStack sourceStack = sourceSlot.getItem();
|
||||
ItemStack copyOfSourceStack = sourceStack.copy();
|
||||
|
||||
// Check if the slot clicked is one of the vanilla container slots
|
||||
if (index < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) {
|
||||
// This is a vanilla container slot so merge the stack into the tile inventory
|
||||
if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX
|
||||
+ TE_INVENTORY_SLOT_COUNT, false)) {
|
||||
return ItemStack.EMPTY; // EMPTY_ITEM
|
||||
}
|
||||
} else if (index < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) {
|
||||
// This is a TE slot so merge the stack into the players inventory
|
||||
if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else {
|
||||
System.out.println("Invalid slotIndex:" + index);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
// If stack size == 0 (the entire stack was moved) set slot contents to null
|
||||
if (sourceStack.getCount() == 0) {
|
||||
sourceSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
sourceSlot.setChanged();
|
||||
}
|
||||
sourceSlot.onTake(playerIn, sourceStack);
|
||||
return copyOfSourceStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
return stillValid(ContainerLevelAccess.create(level, entity.getBlockPos()), player, ModBlocks.COMPRESSION_CHAMBER_BLOCK.get());
|
||||
}
|
||||
|
||||
private static final int PLAYER_INVENTORY_FIRST_SLOT_HEIGHT = 85;
|
||||
private static final int PLAYER_INVENTORY_FIRST_SLOT_LEFT = 11;
|
||||
private static final int PLAYER_HOTBAR_FIRST_SLOT = 143;
|
||||
|
||||
private void addPlayerInventory(Inventory inv)
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 9; j++) {
|
||||
this.addSlot(new Slot(inv, j+i*9+9, PLAYER_INVENTORY_FIRST_SLOT_LEFT+j*18, PLAYER_INVENTORY_FIRST_SLOT_HEIGHT+i*18));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addPlayerHotbar(Inventory inv)
|
||||
{
|
||||
for (int index = 0; index < 9; index++) {
|
||||
this.addSlot(new Slot(inv, index, PLAYER_INVENTORY_FIRST_SLOT_LEFT+index*18, PLAYER_HOTBAR_FIRST_SLOT));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package dev.zontreck.otemod.implementation.compressor;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.MouseHelpers;
|
||||
import dev.zontreck.otemod.implementation.energy.screenrenderer.EnergyInfoArea;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class CompressionChamberScreen extends AbstractContainerScreen<CompressionChamberMenu> {
|
||||
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(OTEMod.MOD_ID, "textures/gui/energized_compression_chamber.png");
|
||||
|
||||
private EnergyInfoArea EIA;
|
||||
|
||||
|
||||
public CompressionChamberScreen(CompressionChamberMenu pMenu, Inventory pPlayerInventory, Component pTitle) {
|
||||
super(pMenu, pPlayerInventory, pTitle);
|
||||
|
||||
this.topPos=0;
|
||||
this.leftPos=0;
|
||||
|
||||
this.imageWidth=176;
|
||||
this.imageHeight=177;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
assignEnergyArea();
|
||||
}
|
||||
|
||||
private void assignEnergyArea() {
|
||||
int x = (width - imageWidth )/2;
|
||||
int y = (height - imageHeight)/2;
|
||||
|
||||
EIA = new EnergyInfoArea(x+63, y+46, menu.entity.getEnergyStorage(), 39, 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics guiGraphics, float v, int i, int i1) {
|
||||
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||
|
||||
|
||||
guiGraphics.blit(TEXTURE, this.leftPos, this.topPos, 0,0, imageWidth, imageHeight);
|
||||
renderCraftingProgress(guiGraphics);
|
||||
EIA.draw(guiGraphics);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics stack, int mouseX, int mouseY)
|
||||
{
|
||||
stack.drawString(font, this.title.getString(), 32, 4, 0xFFFFFF);
|
||||
|
||||
int x = (width - imageWidth )/2;
|
||||
int y = (height - imageHeight)/2;
|
||||
renderEnergy(stack, mouseX, mouseY, x, y);
|
||||
//this.font.draw(stack, this.playerInventoryTitle.getString(), this.leftPos + 17, this.topPos + 123, 0xFFFFFF);
|
||||
}
|
||||
|
||||
private void renderEnergy(GuiGraphics stack, int mouseX, int mouseY, int x, int y) {
|
||||
if(isMouseAbove(mouseX, mouseY, x, y, 63, 46, 39, 6)){
|
||||
stack.renderTooltip(font, EIA.getTooltips(), Optional.empty(), mouseX-x, mouseY-y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void renderCraftingProgress(GuiGraphics stack)
|
||||
{
|
||||
if(menu.isCrafting())
|
||||
{
|
||||
stack.blit(TEXTURE, leftPos+63, topPos+34, 179, 11, menu.getScaledProgress(),6);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics stack, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
renderBackground(stack);
|
||||
super.render(stack, mouseX, mouseY, delta);
|
||||
renderTooltip(stack, mouseX, mouseY);
|
||||
}
|
||||
|
||||
private boolean isMouseAbove(int mouseX, int mouseY, int x, int y, int offsetX, int offsetY, int width, int height)
|
||||
{
|
||||
return MouseHelpers.isMouseOver(mouseX, mouseY, x+offsetX, y+offsetY, width, height);
|
||||
}
|
||||
}
|
|
@ -39,8 +39,12 @@ public class EnergyInfoArea extends InfoArea {
|
|||
@Override
|
||||
public void draw(GuiGraphics transform) {
|
||||
final int height = area.getHeight();
|
||||
final int width = area.getWidth();
|
||||
int stored = (int)(height*(energy.getEnergyStored()/(float)energy.getMaxEnergyStored()));
|
||||
|
||||
transform.fillGradient(area.getX(), area.getY() + (height + stored), area.getX() + area.getWidth(), area.getY() + area.getHeight(), 0xff0000, 0xff550000);
|
||||
|
||||
if(area.getHeight() > area.getWidth())
|
||||
transform.fillGradient(area.getX(), area.getY() + (height + stored), area.getX() + area.getWidth(), area.getY() + area.getHeight(), 0xff0000, 0xff550000);
|
||||
else transform.fillGradient(area.getX() + (width + stored), area.getY(),area.getX() + area.getWidth(), area.getY() + area.getHeight(), 0xff0000, 0xff005500);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package dev.zontreck.otemod.implementation.inits;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.implementation.compressor.CompressionChamberMenu;
|
||||
import dev.zontreck.otemod.implementation.scrubber.ItemScrubberMenu;
|
||||
import dev.zontreck.otemod.implementation.scrubber.MagicalScrubberMenu;
|
||||
import dev.zontreck.otemod.implementation.vault.StarterMenu;
|
||||
|
@ -25,6 +26,8 @@ public final class ModMenuTypes
|
|||
public static final RegistryObject<MenuType<ItemScrubberMenu>> SCRUBBER = registerMenuType(ItemScrubberMenu::new, "item_scrubber_menu");
|
||||
public static final RegistryObject<MenuType<MagicalScrubberMenu>> MAGIC_SCRUBBER = registerMenuType(MagicalScrubberMenu::new, "magical_scrubber_menu");
|
||||
|
||||
public static final RegistryObject<MenuType<CompressionChamberMenu>> COMPRESSION_CHAMBER = registerMenuType(CompressionChamberMenu::new, "compression_chamber");
|
||||
|
||||
|
||||
private static <T extends AbstractContainerMenu> RegistryObject<MenuType<T>> registerMenuType(IContainerFactory<T> factory, String name)
|
||||
{
|
||||
|
|
|
@ -4,10 +4,7 @@ import dev.zontreck.otemod.OTEMod;
|
|||
import dev.zontreck.otemod.blocks.FoiledBlockItem;
|
||||
import dev.zontreck.otemod.entities.ModEntityTypes;
|
||||
import dev.zontreck.otemod.implementation.CreativeModeTabs;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.SimpleFoiledItem;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraftforge.common.ForgeSpawnEggItem;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
|
@ -31,7 +28,13 @@ public class ModItems {
|
|||
|
||||
|
||||
public static final RegistryObject<Item> MELTED_ENDER_PEARL = CreativeModeTabs.addToOTEModTab(ITEMS.register("melted_ender_pearl", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||
public static final RegistryObject<Item> SINGULARITY = CreativeModeTabs.addToOTEModTab(ITEMS.register("singularity", () -> new Item(new Item.Properties().stacksTo(1))));
|
||||
public static final RegistryObject<Item> SINGULARITY = CreativeModeTabs.addToOTEModTab(ITEMS.register("singularity", () -> new UnstableSingularity(new Item.Properties().stacksTo(1))));
|
||||
|
||||
public static final RegistryObject<Item> COMPRESSED_OBSIDIAN_SHEET = CreativeModeTabs.addToOTEModTab(ITEMS.register("compressed_obsidian_sheet", ()->new Item(new Item.Properties())));
|
||||
|
||||
public static final RegistryObject<Item> LAYERED_COMPRESSED_OBSIDIAN_SHEET = CreativeModeTabs.addToOTEModTab(ITEMS.register("layered_compressed_obsidian_sheet", ()->new SimpleFoiledItem(new Item.Properties())));
|
||||
public static final RegistryObject<Item> ENCASED_SINGULARITY = CreativeModeTabs.addToOTEModTab(ITEMS.register("encased_singularity", ()->new SimpleFoiledItem(new Item.Properties())));
|
||||
|
||||
public static final RegistryObject<Item> ETERNIUM_ROD = CreativeModeTabs.addToOTEModTab(ITEMS.register("eternium_rod", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64))));
|
||||
public static final RegistryObject<Item> SCRUBBER_FRAME_PIECE = CreativeModeTabs.addToOTEModTab(ITEMS.register("scrubber_frame_piece", () -> new Item(new Item.Properties().stacksTo(64))));
|
||||
public static final RegistryObject<Item> SCRUBBER_FRAME = CreativeModeTabs.addToOTEModTab(ITEMS.register("scrubber_frame", () -> new Item(new Item.Properties().stacksTo(64))));
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.zontreck.otemod.items;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.lore.ExtraLore;
|
||||
import dev.zontreck.libzontreck.lore.LoreContainer;
|
||||
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||
|
@ -86,12 +87,9 @@ public class ThrownPossBall extends ThrowableItemProjectile
|
|||
captured=true;
|
||||
|
||||
LoreContainer cont = new LoreContainer(getItem());
|
||||
cont.miscData.LoreData.clear();
|
||||
LoreEntry entry = new LoreEntry();
|
||||
entry.bold = true;
|
||||
entry.text = dev.zontreck.libzontreck.chat.ChatColor.doColors("!Dark_Green!Captured Mob: !Dark_Purple!" + entityName);
|
||||
|
||||
cont.miscData.LoreData.add(entry);
|
||||
cont.miscData.loreData.clear();
|
||||
LoreEntry entry = new LoreEntry.Builder().bold(true).text(ChatColor.doColors("!Dark_Green!Captured Mob: !Dark_Purple!" + entityName)).build();
|
||||
cont.miscData.loreData.add(entry);
|
||||
|
||||
cont.commitLore();
|
||||
|
||||
|
@ -136,7 +134,7 @@ public class ThrownPossBall extends ThrowableItemProjectile
|
|||
}
|
||||
|
||||
LoreContainer cont = new LoreContainer(item);
|
||||
cont.miscData.LoreData.clear();
|
||||
cont.miscData.loreData.clear();
|
||||
cont.commitLore();
|
||||
|
||||
if(item.getDamageValue() == 0)
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package dev.zontreck.otemod.items;
|
||||
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.SimpleFoiledItem;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
public class UnstableSingularity extends SimpleFoiledItem
|
||||
{
|
||||
|
||||
public UnstableSingularity(Properties pProperties) {
|
||||
super(pProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext pContext) {
|
||||
BlockState block = pContext.getLevel().getBlockState(pContext.getClickedPos());
|
||||
|
||||
if(block.getBlock().defaultDestroyTime() < 0)
|
||||
{
|
||||
pContext.getLevel().explode(pContext.getPlayer(), pContext.getClickedPos().getX(), pContext.getClickedPos().getY(), pContext.getClickedPos().getZ(), 16, true, Level.ExplosionInteraction.TNT);
|
||||
|
||||
pContext.getLevel().setBlock(pContext.getClickedPos(), Blocks.AIR.defaultBlockState(), 0, 0);
|
||||
|
||||
pContext.getItemInHand().shrink(1);
|
||||
|
||||
}
|
||||
|
||||
return InteractionResult.CONSUME;
|
||||
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package dev.zontreck.otemod.networking.packets;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import dev.zontreck.otemod.blocks.entity.CompressionChamberBlockEntity;
|
||||
import dev.zontreck.otemod.blocks.entity.ItemScrubberBlockEntity;
|
||||
import dev.zontreck.otemod.blocks.entity.MagicalScrubberBlockEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -42,6 +43,9 @@ public class EnergySyncS2CPacket {
|
|||
{
|
||||
entity.setEnergy(energy);
|
||||
} else if(Minecraft.getInstance().level.getBlockEntity(pos) instanceof MagicalScrubberBlockEntity entity)
|
||||
{
|
||||
entity.setEnergy(energy);
|
||||
} else if(Minecraft.getInstance().level.getBlockEntity(pos) instanceof CompressionChamberBlockEntity entity)
|
||||
{
|
||||
entity.setEnergy(energy);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
package dev.zontreck.otemod.recipe;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.*;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CompressionChamberRecipe implements Recipe<SimpleContainer> {
|
||||
private final ResourceLocation id;
|
||||
private final ItemStack output;
|
||||
private final Ingredient input;
|
||||
|
||||
public CompressionChamberRecipe(ResourceLocation id, ItemStack output, Ingredient input)
|
||||
{
|
||||
this.id=id;
|
||||
this.output=output;
|
||||
this.input=input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(SimpleContainer simpleContainer, Level level) {
|
||||
if(level.isClientSide) return false;
|
||||
|
||||
return input.test(simpleContainer.getItem(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack assemble(SimpleContainer simpleContainer, RegistryAccess registryAccess) {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraftInDimensions(int i, int i1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getResultItem(RegistryAccess registryAccess) {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return Serializer.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeType<?> getType() {
|
||||
return Type.INSTANCE;
|
||||
}
|
||||
|
||||
public static class Type implements RecipeType<CompressionChamberRecipe> {
|
||||
private Type(){}
|
||||
|
||||
public static final Type INSTANCE = new Type();
|
||||
public static final String ID = "compressing";
|
||||
}
|
||||
|
||||
public static class Serializer implements RecipeSerializer<CompressionChamberRecipe>
|
||||
{
|
||||
public static final Serializer INSTANCE = new Serializer();
|
||||
public static final ResourceLocation ID = new ResourceLocation(OTEMod.MOD_ID, Type.ID);
|
||||
|
||||
@Override
|
||||
public CompressionChamberRecipe fromJson(ResourceLocation resourceLocation, JsonObject jsonObject) {
|
||||
ItemStack output = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(jsonObject, "output"));
|
||||
|
||||
Ingredient input = Ingredient.fromJson(GsonHelper.getAsJsonObject(jsonObject, "input"));
|
||||
|
||||
return new CompressionChamberRecipe(resourceLocation, output, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable CompressionChamberRecipe fromNetwork(ResourceLocation resourceLocation, FriendlyByteBuf friendlyByteBuf) {
|
||||
ItemStack output = friendlyByteBuf.readItem();
|
||||
|
||||
Ingredient input = Ingredient.fromNetwork(friendlyByteBuf);
|
||||
return new CompressionChamberRecipe(resourceLocation, output, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toNetwork(FriendlyByteBuf friendlyByteBuf, CompressionChamberRecipe compressionChamberRecipe) {
|
||||
friendlyByteBuf.writeItem(compressionChamberRecipe.output);
|
||||
compressionChamberRecipe.input.toNetwork(friendlyByteBuf);
|
||||
}
|
||||
}
|
||||
}
|
19
src/main/java/dev/zontreck/otemod/recipe/ModRecipes.java
Normal file
19
src/main/java/dev/zontreck/otemod/recipe/ModRecipes.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package dev.zontreck.otemod.recipe;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModRecipes {
|
||||
public static final DeferredRegister<RecipeSerializer<?>> SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, OTEMod.MOD_ID);
|
||||
|
||||
public static final RegistryObject<RecipeSerializer<CompressionChamberRecipe>> COMPRESSING_SERIALIZER = SERIALIZERS.register("compressing", ()->CompressionChamberRecipe.Serializer.INSTANCE);
|
||||
|
||||
public static void register(IEventBus bus)
|
||||
{
|
||||
SERIALIZERS.register(bus);
|
||||
}
|
||||
}
|
Reference in a new issue