Skip to content

Commit

Permalink
Remove Common from class names where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Dec 26, 2024
1 parent 34a72a6 commit 467db6d
Show file tree
Hide file tree
Showing 39 changed files with 172 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
* @author rubensworks
*
*/
public abstract class BlockGuiCommon extends Block implements IBlockGui {
public abstract class BlockGui extends Block implements IBlockGui {

public BlockGuiCommon(Properties properties) {
public BlockGui(Properties properties) {
super(properties);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.HitResult;
import org.cyclops.cyclopscore.blockentity.CyclopsBlockEntityCommon;
import org.cyclops.cyclopscore.blockentity.CyclopsBlockEntity;
import org.cyclops.cyclopscore.helper.IModHelpers;

import javax.annotation.Nullable;
Expand All @@ -28,16 +28,16 @@
* By default, the NBT data of block entities will not be persisted,
* unless enabled via {@link #isPersistNbt()}.
* If so, then the {@link #getDroppedItemStackNbt} method will be called
* to call {@link CyclopsBlockEntityCommon#writeToItemStack(CompoundTag, HolderLookup.Provider)}.
* to call {@link CyclopsBlockEntity#writeToItemStack(CompoundTag, HolderLookup.Provider)}.
* This NBT data will automatically be read when placing the block.
*
* @author rubensworks
*/
public abstract class BlockWithEntityCommon extends BaseEntityBlock {
public abstract class BlockWithEntity extends BaseEntityBlock {

private final BiFunction<BlockPos, BlockState, ? extends CyclopsBlockEntityCommon> blockEntitySupplier;
private final BiFunction<BlockPos, BlockState, ? extends CyclopsBlockEntity> blockEntitySupplier;

public BlockWithEntityCommon(Properties properties, BiFunction<BlockPos, BlockState, ? extends CyclopsBlockEntityCommon> blockEntitySupplier) {
public BlockWithEntity(Properties properties, BiFunction<BlockPos, BlockState, ? extends CyclopsBlockEntity> blockEntitySupplier) {
super(properties);
this.blockEntitySupplier = blockEntitySupplier;
}
Expand Down Expand Up @@ -75,7 +75,7 @@ protected ItemStack getDroppedItemStack(BlockState state, HitResult target, Bloc

/**
* Override this method to modify how NBT is constructed for the item.
* By default, {@link CyclopsBlockEntityCommon#writeToItemStack(CompoundTag, HolderLookup.Provider)} will be called.
* By default, {@link CyclopsBlockEntity#writeToItemStack(CompoundTag, HolderLookup.Provider)} will be called.
* @param state A block state.
* @param target The ray trace result.
* @param world The world.
Expand All @@ -87,25 +87,25 @@ protected ItemStack getDroppedItemStack(BlockState state, HitResult target, Bloc
*/
protected CompoundTag getDroppedItemStackNbt(BlockState state, HitResult target, BlockGetter world,
BlockPos blockPos, Player player, ItemStack itemStack,
CyclopsBlockEntityCommon blockEntity) {
CyclopsBlockEntity blockEntity) {
return blockEntity.writeToItemStack(new CompoundTag(), player.level().registryAccess());
}

/**
* If the NBT data of this block entity should be added to the dropped item.
* When overriding this, make sure to override the more sensitive getCloneItemStack methods in Forge and NeoForge,
* and delegate to {@link #getCloneItemStack(BlockWithEntityCommon, Supplier, BlockState, HitResult, LevelReader, BlockPos, Player)}.
* and delegate to {@link #getCloneItemStack(BlockWithEntity, Supplier, BlockState, HitResult, LevelReader, BlockPos, Player)}.
* @return If the NBT data should be added.
*/
public boolean isPersistNbt() {
return false;
}

public static ItemStack getCloneItemStack(BlockWithEntityCommon self, Supplier<ItemStack> superMethod, BlockState state, HitResult target, LevelReader world,
public static ItemStack getCloneItemStack(BlockWithEntity self, Supplier<ItemStack> superMethod, BlockState state, HitResult target, LevelReader world,
BlockPos blockPos, Player player) {
ItemStack itemStack = self.getDroppedItemStack(state, target, world, blockPos, player, superMethod.get());
if (self.isPersistNbt()) {
IModHelpers.get().getBlockEntityHelpers().get(world, blockPos, CyclopsBlockEntityCommon.class).ifPresent(blockEntity -> {
IModHelpers.get().getBlockEntityHelpers().get(world, blockPos, CyclopsBlockEntity.class).ifPresent(blockEntity -> {
CompoundTag compoundnbt = self.getDroppedItemStackNbt(state, target, world, blockPos, player, itemStack, blockEntity);
if (!compoundnbt.isEmpty()) {
itemStack.set(DataComponents.BLOCK_ENTITY_DATA, CustomData.of(compoundnbt));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.cyclops.cyclopscore.blockentity.CyclopsBlockEntityCommon;
import org.cyclops.cyclopscore.blockentity.CyclopsBlockEntity;

import java.util.function.BiFunction;

/**
* Base block with a block entity and gui.
*
* @see BlockWithEntityCommon
* @see BlockGuiCommon
* @see BlockWithEntity
* @see BlockGui
* @author rubensworks
*/
public abstract class BlockWithEntityGuiCommon extends BlockWithEntityCommon implements IBlockGui {
public abstract class BlockWithEntityGui extends BlockWithEntity implements IBlockGui {

public BlockWithEntityGuiCommon(Properties properties, BiFunction<BlockPos, BlockState, ? extends CyclopsBlockEntityCommon> blockEntitySupplier) {
public BlockWithEntityGui(Properties properties, BiFunction<BlockPos, BlockState, ? extends CyclopsBlockEntity> blockEntitySupplier) {
super(properties, blockEntitySupplier);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
*
* @author rubensworks
*/
public class CyclopsBlockEntityCommon extends BlockEntity implements INBTProvider, IDirtyMarkListener, IBlockEntityDelayedTickable {
public class CyclopsBlockEntity extends BlockEntity implements INBTProvider, IDirtyMarkListener, IBlockEntityDelayedTickable {

private static final int UPDATE_BACKOFF_TICKS = 1;

private INBTProvider nbtProviderComponent = new NBTProviderComponent(this);
private boolean shouldSendUpdate = false;
private int sendUpdateBackoff = 0;

public CyclopsBlockEntityCommon(BlockEntityType<?> type, BlockPos blockPos, BlockState blockState) {
public CyclopsBlockEntity(BlockEntityType<?> type, BlockPos blockPos, BlockState blockState) {
super(type, blockPos, blockState);
// Random backoff so not all block entities will be updated at once.
sendUpdateBackoff = (int) Math.round(Math.random() * getUpdateBackoffTicks());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.cyclops.cyclopscore.helper.CyclopsCoreInstance;
import org.cyclops.cyclopscore.helper.IModHelpers;
import org.cyclops.cyclopscore.inventory.IValueNotifiable;
import org.cyclops.cyclopscore.inventory.container.ContainerExtendedCommon;
import org.cyclops.cyclopscore.inventory.container.ContainerExtended;
import org.cyclops.cyclopscore.network.packet.ButtonClickPacket;

import javax.annotation.Nullable;
Expand All @@ -25,7 +25,7 @@
* An extended GUI container.
* @author rubensworks
*/
public abstract class ContainerScreenExtendedCommon<T extends ContainerExtendedCommon> extends AbstractContainerScreen<T>
public abstract class ContainerScreenExtended<T extends ContainerExtended> extends AbstractContainerScreen<T>
implements IValueNotifiable {

private final IModHelpers modHelpers;
Expand All @@ -35,7 +35,7 @@ public abstract class ContainerScreenExtendedCommon<T extends ContainerExtendedC
protected int offsetX = 0;
protected int offsetY = 0;

public ContainerScreenExtendedCommon(T container, Inventory playerInventory, Component title) {
public ContainerScreenExtended(T container, Inventory playerInventory, Component title) {
super(container, playerInventory, title);
this.modHelpers = IModHelpers.get();
this.container = container;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.world.inventory.Slot;
import org.cyclops.cyclopscore.client.gui.component.WidgetScrollBar;
import org.cyclops.cyclopscore.client.gui.component.input.WidgetTextFieldExtended;
import org.cyclops.cyclopscore.inventory.container.ScrollingInventoryContainerCommon;
import org.cyclops.cyclopscore.inventory.container.ScrollingInventoryContainer;
import org.lwjgl.glfw.GLFW;

import java.awt.*;
Expand All @@ -17,14 +17,14 @@
* Gui for an inventory container that has a scrollbar and search field.
* @author rubensworks
*/
public abstract class ContainerScreenScrollingCommon<T extends ScrollingInventoryContainerCommon> extends ContainerScreenExtendedCommon<T> {
public abstract class ContainerScreenScrolling<T extends ScrollingInventoryContainer> extends ContainerScreenExtended<T> {

private static final int SEARCH_WIDTH = 89;

private WidgetTextFieldExtended searchField = null;
private WidgetScrollBar scrollbar = null;

public ContainerScreenScrollingCommon(T container, Inventory playerInventory, Component title) {
public ContainerScreenScrolling(T container, Inventory playerInventory, Component title) {
super(container, playerInventory, title);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @author rubensworks
*
*/
public class IndexedInventoryCommon extends LargeInventoryCommon implements IInventoryIndexReference {
public class IndexedInventory extends LargeInventory implements IInventoryIndexReference {

private final Map<Item, Int2ObjectMap<ItemStack>> index = Maps.newIdentityHashMap();
private IntSet emptySlots;
Expand All @@ -28,7 +28,7 @@ public class IndexedInventoryCommon extends LargeInventoryCommon implements IInv
/**
* Default constructor for NBT persistence, don't call this yourself.
*/
public IndexedInventoryCommon() {
public IndexedInventory() {
this(0, 0);
}

Expand All @@ -37,7 +37,7 @@ public IndexedInventoryCommon() {
* @param size The amount of slots in the inventory.
* @param stackLimit The stack limit for each slot.
*/
public IndexedInventoryCommon(int size, int stackLimit) {
public IndexedInventory(int size, int stackLimit) {
super(size, stackLimit);
this.emptySlots = new IntAVLTreeSet();
this.nonEmptySlots = new IntAVLTreeSet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ResourceLocation getUniqueName() {
}
@Override
public IInventoryCommonModifiable getInventory(Player player) {
return new InventoryCommonModifiableContainer(player.getInventory());
return new InventoryModifiableContainer(player.getInventory());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
/**
* @author rubensworks
*/
public class InventoryCommonModifiableContainer implements IInventoryCommonModifiable {
public class InventoryModifiableContainer implements IInventoryCommonModifiable {

private final Container container;

public InventoryCommonModifiableContainer(Container container) {
public InventoryModifiableContainer(Container container) {
this.container = container;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
* @author rubensworks
*
*/
public class LargeInventoryCommon extends SimpleInventoryCommon {
public class LargeInventory extends SimpleInventory {

/**
* Default constructor for NBT persistence, don't call this yourself.
*/
public LargeInventoryCommon() {
public LargeInventory() {
this(0, 0);
}

Expand All @@ -25,7 +25,7 @@ public LargeInventoryCommon() {
* @param size The amount of slots in the inventory.
* @param stackLimit The stack limit for each slot.
*/
public LargeInventoryCommon(int size, int stackLimit) {
public LargeInventory(int size, int stackLimit) {
super(size, stackLimit);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
public class PlayerInventoryIterator extends InventoryIterator {

public PlayerInventoryIterator(Player player) {
super(new InventoryCommonModifiableContainer(player.getInventory()));
super(new InventoryModifiableContainer(player.getInventory()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@
* @author rubensworks
*
*/
public class SimpleInventoryCommon implements INBTInventory, WorldlyContainer {
public class SimpleInventory implements INBTInventory, WorldlyContainer {

public static final Codec<SimpleInventoryCommon> CODEC = RecordCodecBuilder.create((builder) -> builder
.group(Codec.INT.fieldOf("size").forGetter(SimpleInventoryCommon::getContainerSize),
Codec.INT.fieldOf("stackLimit").forGetter(SimpleInventoryCommon::getMaxStackSize),
public static final Codec<SimpleInventory> CODEC = RecordCodecBuilder.create((builder) -> builder
.group(Codec.INT.fieldOf("size").forGetter(SimpleInventory::getContainerSize),
Codec.INT.fieldOf("stackLimit").forGetter(SimpleInventory::getMaxStackSize),
ItemStack.OPTIONAL_CODEC.listOf().fieldOf("contents").forGetter(i -> Arrays.asList(i.getItemStacks())))
.apply(builder, SimpleInventoryCommon::new));
public static final StreamCodec<RegistryFriendlyByteBuf, SimpleInventoryCommon> STREAM_CODEC = StreamCodec.composite(
ByteBufCodecs.INT, SimpleInventoryCommon::getContainerSize,
ByteBufCodecs.INT, SimpleInventoryCommon::getMaxStackSize,
.apply(builder, SimpleInventory::new));
public static final StreamCodec<RegistryFriendlyByteBuf, SimpleInventory> STREAM_CODEC = StreamCodec.composite(
ByteBufCodecs.INT, SimpleInventory::getContainerSize,
ByteBufCodecs.INT, SimpleInventory::getMaxStackSize,
ItemStack.OPTIONAL_STREAM_CODEC.apply(ByteBufCodecs.list()), i -> Arrays.asList(i.getItemStacks()),
SimpleInventoryCommon::new
SimpleInventory::new
);

protected final ItemStack[] contents;
Expand All @@ -50,7 +50,7 @@ public class SimpleInventoryCommon implements INBTInventory, WorldlyContainer {
/**
* Default constructor for NBT persistence, don't call this yourself.
*/
public SimpleInventoryCommon() {
public SimpleInventory() {
this(0, 0);
}

Expand All @@ -59,15 +59,15 @@ public SimpleInventoryCommon() {
* @param size The amount of slots in the inventory.
* @param stackLimit The stack limit for each slot.
*/
public SimpleInventoryCommon(int size, int stackLimit) {
public SimpleInventory(int size, int stackLimit) {
contents = new ItemStack[size];
for (int i = 0; i < contents.length; i++) {
contents[i] = ItemStack.EMPTY;
}
this.stackLimit = stackLimit;
}

public SimpleInventoryCommon(int size, int stackLimit, List<ItemStack> contents) {
public SimpleInventory(int size, int stackLimit, List<ItemStack> contents) {
this.contents = new ItemStack[size];
for (int i = 0; i < this.contents.length; i++) {
this.contents[i] = contents.get(i);
Expand Down Expand Up @@ -288,9 +288,9 @@ public boolean canTakeItemThroughFace(int index, ItemStack stack, Direction dire
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SimpleInventoryCommon)) return false;
if (!(o instanceof SimpleInventory)) return false;

SimpleInventoryCommon that = (SimpleInventoryCommon) o;
SimpleInventory that = (SimpleInventory) o;

if (stackLimit != that.stackLimit) return false;
if (contents.length != that.contents.length) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
* A container with inventory.
* @author rubensworks
*/
public abstract class ContainerExtendedCommon extends AbstractContainerMenu implements IContainerButtonClickAcceptorServer<ContainerExtendedCommon>,
public abstract class ContainerExtended extends AbstractContainerMenu implements IContainerButtonClickAcceptorServer<ContainerExtended>,
IValueNotifier, IValueNotifiable {

private static final EquipmentSlot[] EQUIPMENT_SLOTS = new EquipmentSlot[] {
EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET};
protected static final int ITEMBOX = 18;

private final Map<String, IContainerButtonAction<ContainerExtendedCommon>> buttonActions = Maps.newHashMap();
private final Map<String, IContainerButtonAction<ContainerExtended>> buttonActions = Maps.newHashMap();
private final Map<Integer, CompoundTag> values = Maps.newHashMap();
private final List<SyncedGuiVariable<?>> syncedGuiVariables = Lists.newArrayList();
private int nextValueId = 0;
Expand All @@ -63,7 +63,7 @@ public abstract class ContainerExtendedCommon extends AbstractContainerMenu impl
* @param id The container id.
* @param inventory The player inventory.
*/
public ContainerExtendedCommon(@Nullable MenuType<?> type, int id, Inventory inventory) {
public ContainerExtended(@Nullable MenuType<?> type, int id, Inventory inventory) {
super(type, id);
this.playerIInventory = inventory;
this.player = inventory.player;
Expand Down Expand Up @@ -438,13 +438,13 @@ protected void fillPhantomSlot(Slot slot, ItemStack stackHeld, int mouseButton,
}

@Override
public void putButtonAction(String buttonId, IContainerButtonAction<ContainerExtendedCommon> action) {
public void putButtonAction(String buttonId, IContainerButtonAction<ContainerExtended> action) {
buttonActions.put(buttonId, action);
}

@Override
public boolean onButtonClick(String buttonId) {
IContainerButtonAction<ContainerExtendedCommon> action;
IContainerButtonAction<ContainerExtended> action;
if((action = buttonActions.get(buttonId)) != null) {
action.onAction(buttonId, this);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*
* @author rubensworks
*/
public class ContainerTypeDataCommon<T extends AbstractContainerMenu> extends MenuType<T> {
public ContainerTypeDataCommon(IContainerFactoryCommon<T> factory, FeatureFlagSet featureFlagSet) {
public class ContainerTypeData<T extends AbstractContainerMenu> extends MenuType<T> {
public ContainerTypeData(IContainerFactoryCommon<T> factory, FeatureFlagSet featureFlagSet) {
super(factory, featureFlagSet);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
* A container for an inventory.
* @author rubensworks
*/
public abstract class InventoryContainerCommon extends ContainerExtendedCommon {
public abstract class InventoryContainer extends ContainerExtended {

protected final Container inventory;

public InventoryContainerCommon(@Nullable MenuType<?> type, int id, Inventory playerInventory, Container inventory) {
public InventoryContainer(@Nullable MenuType<?> type, int id, Inventory playerInventory, Container inventory) {
super(type, id, playerInventory);
this.inventory = inventory;
if (isAssertInventorySize()) {
Expand Down
Loading

0 comments on commit 467db6d

Please sign in to comment.