Skip to content

Commit

Permalink
Added clamp functions, changes to block interacts
Browse files Browse the repository at this point in the history
  • Loading branch information
Fureniku committed Feb 24, 2024
1 parent c03f4d2 commit a92fc2c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/fureniku/metropolis/RegistrationBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public RegistrationBase(String modid, IEventBus modEventBus) {
//modEventBus.addListener(this::modelInit);
//modEventBus.addListener(this::modelBakeComplete);
//modEventBus.addListener(this::modifyBake);
modEventBus.addListener(this::guiOverlay);
//modEventBus.addListener(this::guiOverlay);
}

modEventBus.addListener(this::generate);
Expand Down Expand Up @@ -332,12 +332,12 @@ protected void guiOverlay(RegisterGuiOverlaysEvent event) {


//Add a block to the registry
private void addBlock(String key, RegistryObject<Block> value) {
protected void addBlock(String key, RegistryObject<Block> value) {
block_map.put(key, value);
}

//Add an item to the registry
private void addItem(String key, RegistryObject<Item> value) {
protected void addItem(String key, RegistryObject<Item> value) {
item_map.put(key, value);
}
}
8 changes: 4 additions & 4 deletions src/main/java/com/fureniku/metropolis/blocks/BlockSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ private void init(RegistrationBase register) {
*/
public BlockSet addColorTints(IEventBus modEventBus, BiFunction<BlockAndTintGetter, BlockPos, Integer> blockColor, Supplier<Integer> itemColor) {
if (FMLEnvironment.dist.isClient()) {
modEventBus.addListener(this::registerBlockColors);
modEventBus.addListener(this::registerItemColors);
tintColorBlock = blockColor;
tintColorItem = itemColor;
//modEventBus.addListener(this::registerBlockColors);
//modEventBus.addListener(this::registerItemColors);
//tintColorBlock = blockColor;
//tintColorItem = itemColor;
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public BlockState getStateForPlacement(BlockPlaceContext context) {
@Override
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult result) {
if (hand == InteractionHand.MAIN_HAND) {
return onRightClick(state, level, pos, player);
onRightClick(state, level, pos, player);
}
return onUse(state, level, pos, player, hand, result);
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/fureniku/metropolis/utils/SimpleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,24 @@ public static <T>boolean containsType(Class<? extends T> type, T... list) {
}
return false;
}

public static int clamp(int val, int min, int max) {
if (val < min) {
return min;
}
if (val > max) {
return max;
}
return val;
}

public static float clamp(float val, float min, float max) {
if (val < min) {
return min;
}
if (val > max) {
return max;
}
return val;
}
}

0 comments on commit a92fc2c

Please sign in to comment.